Ads by Google

Showing posts with label outline mode. Show all posts
Showing posts with label outline mode. Show all posts

Wednesday, December 4, 2013

A few unrelated Emacs tips

I used to prefer installing things by hand but now I'm not so sure after using Emacs package manager.  Add this to your .emacs and do a M-x list-packages to see the list of packages that are available for Emacs.

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "http://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.milkbox.net/packages/")))

Yes, not all packages are there; yes, the sites go down sometime, yes it's goes into .emacs.d folder in your relevant OS.   It works smoothly and it saves you a lot of hassle in scouring the net for stuff which overrides the minor inconveniences.

Use outline-mode in your AucTeX mode when editing LaTeX files as outline-minor-mode and while you're at it, do install OutlineMagic to handle the not-so-easy-keychord issue of outline-mode.  I've mapped mine to PF12 key.
 (eval-after-load 'outline
  '(progn
    (require 'outline-magic)
    (define-key outline-minor-mode-map (kbd "<\f12>") 'outline-cycle)))

If you ever had the need to copy your gcc messages to different folders at the same time when sending out emails in gnus, then this thread might be of use to you. Currently doesn't work with group names with spaces in their names especially IMAP folders.

Sunday, April 27, 2008

Binding Keys in Emacs

In Emacs, the keys can be rebound to call any function one desires.One of the many uses of rebinding is to call frequent functions that are operated on the buffer one is working on. And the key bindings can be local or global depending upon whether the functionality makes sense across all buffers or only to the type of buffers worked on (text, tex etc.)

Here for example is what I have mapped for TeX mode. I have outline-mode enabled by default for LaTeX files.
(add-hook 'LaTeX-mode-hook
(function (lambda ()
(setq fill-column 68)
(auto-fill-mode t)
(flyspell-mode 1)
(TeX-PDF-mode 1) ;;turn on PDF mode.
(outline-minor-mode t)
(ruler-mode t)
(local-set-key "\C-cf" 'beamer-template-frame)
(setq ispell-extra-args '("--mode=tex"))
(paren-toggle-matching-quoted-paren 1)
(paren-toggle-matching-paired-delimiter 1))))
Now, this puts an outline-mode menu on the menu-bar whose keybindings
are atrocious! :-)

Now in outline-mode, the most frequently used functions are

Show All
Show Entry
Hide Body
Hide Entry

at least by me.

Now, I'd like to map the keys as follows

Hide Body F7

Show All S-F7 shift F7
Hide Entry F8

Show Entry S-F8 shift F8

Next, open a LaTeX file and enable outline-mode, if it has not been done so. Then, M-x local-set-key RET f7 hide-body. Test it by hitting F7. If it works, then do C-x ESC ESC, you should see the following form in the minibuffer. Copy it to the scratch buffer. Repeat the above M-x local-set-key with S-F7 to bind it to show-all and copy the form to the scratch buffer.

You should have something like this in your scratch buffer.
(local-set-key (quote [f7]) (quote hide-body))
(local-set-key (quote [S-f7]) (quote show-all))
Repeat the above actions for hide-entry and show-entry to use F8. Of course you can bind it to any other key than the suggested F7 & F8 function keys. If you're happy with it, you could add it to the LaTeX-mode-hook function after the outline-mode is enabled.

Note that the idea of C-x ESC ESC ( repeat-complex-command) to get the key bindings is got from here. As the post suggests, it's far easier to let Emacs generate the correct key binding forms instead of doing it by hand.

And it might be a good idea to associate some logic to the key bindings. I use the key and shift key to toggle between two opposite actions. At least that sounds logical to me.

Monday, April 21, 2008

Increase your productivity with Minor Modes

One of the features that increases your productivity are the minor modes that can be enabled to help your work. Abbreviation mode, Foot note mode, flyspell mode are some of the minor modes that allow you to correct typos, add footnotes and do spell check.

In addition there are lots of other minor modes have been added to the main branch of Emacs that can complement the existing ones.

Like Table, that allows you to create ASCII tables to align text and also create spiffy text based tables. It also provides a LaTeX export function that helps in creating a LaTeX table. Frankly, I've been using the table-insert function to create all my LaTeX tables. Saves me the repetitive edit-view-correct cycle by a huge margin.

Another simple one is ruler-mode that puts a ruler on top of the text area. If you do a M-x find-file RET ruler-mode, the commentary will explain what are the features you can use enabling the minor mode. Tremendously useful when working with fixed width data; slightly better than following the mode line for the column position, I dare say.

And one other under appreciated mode for newbies and intermediate Emacs users is outline-mode. Found in org-mode and one that can be set in LaTeX mode (with AucTeX), the showing and hiding of the sections allows one to navigate large documents quite easily. Instead of scrolling up and down the document, it's easier to fold the arbitrary sections to focus on the section at hand.