Emacs tips and tricks
Forum rules
Share your brain ;)
Share your brain ;)
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
Thanks for this howto! Recently I have been playing around with different typesetting modes like LaTeX and markdown and other wiki styles. Emacs does this thing very well, and org-mode is basically nothing else than a powerful blog frontend.
Really superb write-up!
Really superb write-up!
..gnutella..
Re: Emacs tips and tricks
^ thank you, I feel I have to do something because I stole too much from DebianJoe's writings in the past. ;)
I still have to explore (and appreciate) LaTeX and how it works with Emacs, but I'll do it soon.
I still have to explore (and appreciate) LaTeX and how it works with Emacs, but I'll do it soon.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
^ Please do!
Another quick one for all you org-mode lovers.
I use org-mode for todo-lists, and I got plenty of them. You should already know that if you put something like "[/]" beside the parent node of a todo list, that little thingy will become something like "[2/10]". Basically, it is telling you how many of your todos are marked as DONE. Very useful.
I don't need to keep all my DONE tasks forever, so every now and then I clean my lists deleting DONE tasks. Org-mode, by default, doesn't update the TODO counter (let's call it like this, for now) when you delete a DONE task.
So, as suggested by the almight What the .emacs.d!?, you can add this to your .emacs and automate the process of updating the TODO counter:
Now, whenever I kill the DONE task line with a simple C^k, the TODO counter is automagically updated.
Another quick one for all you org-mode lovers.
I use org-mode for todo-lists, and I got plenty of them. You should already know that if you put something like "[/]" beside the parent node of a todo list, that little thingy will become something like "[2/10]". Basically, it is telling you how many of your todos are marked as DONE. Very useful.
I don't need to keep all my DONE tasks forever, so every now and then I clean my lists deleting DONE tasks. Org-mode, by default, doesn't update the TODO counter (let's call it like this, for now) when you delete a DONE task.
So, as suggested by the almight What the .emacs.d!?, you can add this to your .emacs and automate the process of updating the TODO counter:
Code: Select all
;; Org-mode: update parent nodes when child is removed
(defun myorg-update-parent-cookie ()
(when (equal major-mode 'org-mode)
(save-excursion
(ignore-errors
(org-back-to-heading)
(org-update-parent-todo-statistics)))))
(defadvice org-kill-line (after fix-cookies activate)
(myorg-update-parent-cookie))
(defadvice kill-whole-line (after fix-cookies activate)
(myorg-update-parent-cookie))
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
Little keymap fix for emacs -nw:
If - for whatever reasons - you cannot produce a Alt-x to execute extended commands (and you are too lazy to press Esc, or whatever) because it prints out some strange character like a œ or æ, add the following line to your Xresources:
If - for whatever reasons - you cannot produce a Alt-x to execute extended commands (and you are too lazy to press Esc, or whatever) because it prints out some strange character like a œ or æ, add the following line to your Xresources:
Code: Select all
*metaSendsEscape:true
..gnutella..
Re: Emacs tips and tricks
Maybe an obvious one, but for any of you Emacs users tired of GTK3 forced in when you install Emacs via apt-get, here is the solution. Of course you can also go with emacs-nox and work just fine. Stop reading, then, you are already happy. I'm writing this for the ones who use Emacs with X and their favorite WM.
We are going to compile Emacs, because we love compiling don't we? Let's go.
First of all, get the latest version of Emacs. If you want the stable one do:
If you want the latest alpha/test/bleeding/oh-dear-lord-I'm-scared release do:
Extract the archive wherever you want, and cd into the new directory. Having Emacs working with GTK2 instead of GTK3 is just a matter of doing this:
Really, it is THAT simple.
Now make it and install it:
That's about it. Enjoy your GTK2. :)
We are going to compile Emacs, because we love compiling don't we? Let's go.
First of all, get the latest version of Emacs. If you want the stable one do:
Code: Select all
wget http://ftpmirror.gnu.org/emacs/emacs-24.3.tar.gz
Code: Select all
wget ftp://alpha.gnu.org/gnu/emacs/pretest/emacs-24.3.92.tar.xz
Code: Select all
./configure --with-x-toolkit=gtk2
Now make it and install it:
Code: Select all
make
sudo make install
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
^ or take the lucid version :) But yes, thanks for the reminder. Actually a shame they don't add a gtk2-forced package to the repos -- for everything else they have shit there :)
..gnutella..
Re: Emacs tips and tricks
^ oh yes, you're right, I forgot about the lucid version. Arch got the gtk2 version, IIRC.
Re: Emacs tips and tricks
Another one just for you Emacs lovers. This one is about RSS feed. There are many ways to read our feeds. We have newsbeuter and nrss, of course. In Emacs we already have gnus, so why bother with yet another one? Just because.
This one is called elfeed. The website explains the reason behind it, but the important thing is:
Let's go.
First of all, grab the sources via git:
cd into the elfeed directory and compile the little bastard:
Now it is just a matter of setting elfeed up in our .emacs file. Check your paths and add these lines:
You can just add whatever feed you want in there.
Now fire up your Emacs, hit C^x w and elfeed should start. You'll see nothing at first but don't be afraid. Hit G (yep, capital) and you'll get what you are looking for.
This one is called elfeed. The website explains the reason behind it, but the important thing is:
Author also says elfeed is availbale on MELPA, but I couldn't install it. So I grabbed the sources and made it work anyway like guys like us always do.elfeed is oriented around entries -- the Atom term for articles -- rather than feeds. It cares less about where entries came from and more about listing relevant entries for reading
Let's go.
First of all, grab the sources via git:
Code: Select all
git clone https://github.com/skeeto/elfeed
Code: Select all
cd elfeed
make
Code: Select all
(add-to-list 'load-path "~/.emacs.d/elfeed")
(require 'elfeed)
(global-set-key (kbd "C-x w") 'elfeed)
(setq elfeed-feeds
'("http://kmandla.wordpress.com/feed/"
"http://inconsolation.wordpress.com/feed/"))
Now fire up your Emacs, hit C^x w and elfeed should start. You'll see nothing at first but don't be afraid. Hit G (yep, capital) and you'll get what you are looking for.
Re: Emacs tips and tricks
machinebacon wrote:http://www.finseth.com/craft/
Title The Craft of Text Editing: Emacs for the Modern World
Author(s) Craig A. Finseth
Publisher: Lulu.com; 3rd edition (March 17, 2006)
Paperback 228 pages
eBook Online, HTML, PDF files
Language: English
ISBN-10: 1411682971
ISBN-13: 978-1411682979
A bit late, but thanks a bunch for the book Bacon!
Re: Emacs tips and tricks
Emacs as OS? Common joke? No!
http://c2.com/cgi/wiki?EmacsAsOperatingSystem
http://www.informatimago.com/linux/emac ... linux.html
http://c2.com/cgi/wiki?EmacsAsOperatingSystem
http://www.informatimago.com/linux/emac ... linux.html
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer
Re: Emacs tips and tricks
How are experiences with emacs-noX? Personally I've had conflicts, such as finding a prefix for TMUX, and urxvt (e.g. C-M-v scrolls help in emacs, paste in urxvt).
It's funny how we used to be able to do real stuff with rudimentary computers, but now we can't. -- ratcheer
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
@alad, to be honest I prefer the noX version to any with toolkit - but then again I only run emacs in TTY. Actually (well...) Emacs doesn't need to be run in tmux, tell you two reasons: one is, that Emacs itself works with frames and buffers (let me recommend e2wm for this), and secondly because you can 'pretend' to use different (tmux)windows by switching through the TTYs (Alt-cursor). Emacs in tty1, tmux can run on tty2, for example, and you have a radio script running in tty7, and a full-screen clock as 'screen saver' on tty8. This is just a usage example :)
@bones, thank you for the link!
@bones, thank you for the link!
..gnutella..
Re: Emacs tips and tricks
Some nice adds to your config if you are looking for Naked Emacs, as someone smarter than me calls it.
Code: Select all
;; turn off blinking cursor
(blink-cursor-mode 0)
;; turn off mouse interface early in startup to avoid momentary display
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'horizontal-scroll-bar-mode) (horizontal-scroll-bar-mode -1))
;; disable annoying prompts
(fset 'yes-or-no-p 'y-or-n-p)
(setq kill-buffer-query-functions
(remq 'process-kill-buffer-query-function
kill-buffer-query-functions))
;; disable splash screen
(setq inhibit-startup-message t
inhibit-startup-echo-area-message t)
;; disable scratch buffer message
(setq initial-scratch-message nil)
;; tooltips in the echo area
(tooltip-mode -1)
(setq tooltip-use-echo-area t)
;; minor mode to hide the mode line (see http://bzg.fr/emacs-hide-mode-line.html)
(defvar-local hidden-mode-line-mode nil)
(defvar-local hide-mode-line nil)
(define-minor-mode hidden-mode-line-mode
"Minor mode to hide the mode-line in the current buffer."
:init-value nil
:global t
:variable hidden-mode-line-mode
:group 'editing-basics
(if hidden-mode-line-mode
(setq hide-mode-line mode-line-format
mode-line-format nil)
(setq mode-line-format hide-mode-line
hide-mode-line nil))
(force-mode-line-update)
;; Apparently force-mode-line-update is not always enough to
;; redisplay the mode-line
(redraw-display)
(when (and (called-interactively-p 'interactive)
hidden-mode-line-mode)
(run-with-idle-timer
0 nil 'message "Hidden Mode Line Mode enabled.")))
;; if you want to hide the mode-line in every buffer by default
(add-hook 'after-change-major-mode-hook 'hidden-mode-line-mode)
;; custom keybindings activated with C^x t (see http://endlessparentheses.com/the-toggle-map-and-wizardry.html)
(define-prefix-command 'toggle-map)
;; The manual recommends C-c for user keys, but C-x t is
;; always free, whereas C-c t is used by some modes.
(define-key ctl-x-map "t" 'toggle-map)
(define-key toggle-map "v" 'visual-line-mode)
(define-key toggle-map "c" 'column-number-mode)
(define-key toggle-map "l" 'linum-mode)
(define-key toggle-map "h" 'hidden-mode-line-mode)
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
You are writing a text and need to calculate something and paste the result directly where the point is?
M-x quick-calc (or: M-# q)
Enter your calculation in the minibuffer
C-j to send the result to the point (Enter sends it to kill-ring)
M-x quick-calc (or: M-# q)
Enter your calculation in the minibuffer
C-j to send the result to the point (Enter sends it to kill-ring)
..gnutella..
Re: Emacs tips and tricks
^ really handy!
Re: Emacs tips and tricks
I don't know how many of you out there use eshell, but I've been using it lately. Though it will be hard for eshell to get me away from zsh, I appreciate some of the few features I tried. Can't run mutt nor newsbeuter in it, but of course Emacs got its replacements for those, so whatever. Jokes aside, it is nice not to leave Emacs for some basic operations I usually need to do with zsh.
First of all, type M^x eshell to open it.
There are some coreutils commands re-implemented in elisp, but the transition is smooth and you won't notice the difference (maybe). Type ls, for instance.
One thing I found pretty useful is find-file. Using that command you can open a file straight into Emacs from eshell. Since typing find-file everytime is quite boring, enter aliases. Type:
Much better. I also did the same for dired:
There is no clear command, though, and when the buffer becomes pretty full of stuff I just need to clear that damn thing. So here we go:
Ok, this is trivial stuff of course. Have a read here for more: http://www.masteringemacs.org/articles/ ... ng-eshell/
First of all, type M^x eshell to open it.
There are some coreutils commands re-implemented in elisp, but the transition is smooth and you won't notice the difference (maybe). Type ls, for instance.
One thing I found pretty useful is find-file. Using that command you can open a file straight into Emacs from eshell. Since typing find-file everytime is quite boring, enter aliases. Type:
Code: Select all
alias ff find-file $1
Code: Select all
alias d dired $1
Code: Select all
;; clear shell
;; (see http://www.khngai.com/emacs/eshell.php)
(defun eshell/clear ()
"clear the eshell buffer."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
You could also just M-x shell :) This brings the real thing :D
..gnutella..
Re: Emacs tips and tricks
^ oh yes, I did know that, but eshell is intriguing (or mind-blowing, it depends). ;)