Postings on living in an Emacs world. Posts will be mostly on using Emacs, related functions and tools.
Ads by Google
Tuesday, April 29, 2008
How to start a massive flamewar!
When you make a blog posting like this. Armageddon time. :-)
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.
are atrocious! :-)
Now in outline-mode, the most frequently used functions are
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.
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.
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 keybindingsare 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))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.
(local-set-key (quote [S-f7]) (quote show-all))
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.
Friday, April 25, 2008
Proved Right!
Back then, I speculated that the reason Sun bought out MySQL was probably due to its spat with Oracle over pricing multicore chips.
Well, this story sort of confirms that.
Pricing on a processor based system is now more complex with cores more than 1. and it's going to sock the first guy with more cores per chip, from their trusted partners.
Well, this story sort of confirms that.
Pricing on a processor based system is now more complex with cores more than 1. and it's going to sock the first guy with more cores per chip, from their trusted partners.
Wednesday, April 23, 2008
What did they have in mind....
when a variable called track-eol is created which you can set as
I've enabled it in the past and I can't say I found it tremendously useful and wondering if anyone has ever seen some good use for it. It's mentioned in the manual. Drop me a line if you ever think of a good use for it. I have a nebulous thought it might be useful for fixed width data files?
*shrug*
Copy it to the scratch buffer, eval it and open a few text files and see whether you like it all.
Apparently if you set this to a non-nil value and if you're at the end of a line, C-n and C-p will track up or down to the end of the line you just moved to.
(setq track-eol t) ?
I've enabled it in the past and I can't say I found it tremendously useful and wondering if anyone has ever seen some good use for it. It's mentioned in the manual. Drop me a line if you ever think of a good use for it. I have a nebulous thought it might be useful for fixed width data files?
*shrug*
Copy it to the scratch buffer, eval it and open a few text files and see whether you like it all.
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.
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.
Saturday, April 19, 2008
The closest to text intellisense in Emacs
Emacs users know that M-/ is used to the expand the text at point for possible completions. One good thing is that it searches all the buffers for possible completions. While this is not the same as programming language intellisense stuff you find in programming editors from Microsoft, Sun and Eclipse, it's still a better choice than a language specific offering.
Why? Because it gives the same consistent behaviour in whatever buffer you're in. You can be sure that if you had typed it before, it can be plugged into the current buffer in whatever mode it is in with a minimal of keystrokes. This is in contrast to other specialised editors which can offer the feature for Java, C or C++, say.
OK, the choice of M-/ is not exactly great for those who are not good typists.
But this is Emacs; there is a way to use TAB as the more natural keystroke to expand the text at point. Plugging in the code given at this link will make text expansion or completion a lot more natural. Having done that, I've pretty much stopped using M-/ for text expansion.
One other way to do text completion is to use Predictive mode which learns from your typing style; Having used it before, I could see the benefits but I ran into some resource usage errors with the dictionary and hence stopped using it.
I'd encourage people to try predictive mode if only to see the possibilities that might arise for you. A typing session that is customised to the way you write. It might be very useful for people who are in some specialised fields with limited but large words usage.
Why? Because it gives the same consistent behaviour in whatever buffer you're in. You can be sure that if you had typed it before, it can be plugged into the current buffer in whatever mode it is in with a minimal of keystrokes. This is in contrast to other specialised editors which can offer the feature for Java, C or C++, say.
OK, the choice of M-/ is not exactly great for those who are not good typists.
But this is Emacs; there is a way to use TAB as the more natural keystroke to expand the text at point. Plugging in the code given at this link will make text expansion or completion a lot more natural. Having done that, I've pretty much stopped using M-/ for text expansion.
One other way to do text completion is to use Predictive mode which learns from your typing style; Having used it before, I could see the benefits but I ran into some resource usage errors with the dictionary and hence stopped using it.
I'd encourage people to try predictive mode if only to see the possibilities that might arise for you. A typing session that is customised to the way you write. It might be very useful for people who are in some specialised fields with limited but large words usage.
Thursday, April 17, 2008
LaTeX tip: Always use small fonts for Verbatim environment
On the TeX newsgroup, this was a nice tip to use. Indented code tends to move off the paper with normal fonts and the only way was to wrap the verbatim environment under \small.
But you'd have to do that for every verbatim listing.
Making the change in the document preamble makes the code listing simple.
For those interested in more sophisticated LaTeX pretty printing, the listings package is pretty good and comes with support for a number of languages. For anything fancier than the normal verbatim environment, that is a very good package to use.
But you'd have to do that for every verbatim listing.
Making the change in the document preamble makes the code listing simple.
For those interested in more sophisticated LaTeX pretty printing, the listings package is pretty good and comes with support for a number of languages. For anything fancier than the normal verbatim environment, that is a very good package to use.
Tuesday, April 15, 2008
Cleaning up or Deleting LaTeX intermediate files using AucTeX
Anyone using LaTeX knows that there are a number of intermediate files that are generated in the course of compiling the document. After the final file is generated, there is no need to keep those files around. But one has to delete them manually or plug the extensions in a shell script to delete them.
Fortunately AucTeX provides a simple interface to clean the files. Hitting C-c C-c and typing 'Clean' or 'Clean All' deletes the intermediate files associated with the current .tex in the buffer.
That's right, it ONLY deletes the intermediate files with respect to the current buffer where C-c C-c is called.
The difference between 'Clean' and 'Clean All' is that, in the latter case, the output files are also deleted. And the files can also be deleted by calling M-x TeX-clean.
So, what intermediate files are deleted? Depending on the type of file being edited, it varies. For example, for LaTeX files, it's
To know the exact way things can be customised, see the AucTeX manual, especially Cleaning.
Fortunately AucTeX provides a simple interface to clean the files. Hitting C-c C-c and typing 'Clean' or 'Clean All' deletes the intermediate files associated with the current .tex in the buffer.
That's right, it ONLY deletes the intermediate files with respect to the current buffer where C-c C-c is called.
The difference between 'Clean' and 'Clean All' is that, in the latter case, the output files are also deleted. And the files can also be deleted by calling M-x TeX-clean.
So, what intermediate files are deleted? Depending on the type of file being edited, it varies. For example, for LaTeX files, it's
LaTeX-clean-intermediate-suffixes is a variable defined in `latex.el'.
Its value is ("\\.aux" "\\.bbl" "\\.blg" "\\.brf" "\\.fot" "\\.glo"
"\\.gls" "\\.idx" "\\.ilg" "\\.ind" "\\.lof" "\\.log" "\\.lot"
"\\.nav" "\\.out" "\\.snm" "\\.toc" "\\.url")
To know the exact way things can be customised, see the AucTeX manual, especially Cleaning.
Monday, April 14, 2008
In my previous post, I outlined how to get Auctex to launch Acrobat Reader. Here's a minor change based on the same poster's advice. If the reader is the default application to view pdf files in Windows, you don't even need the acrord32 in the configuration. Just
is enough.
TeX-output-view-style is a variable defined in `tex.el'.
Its value is
(("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "dvips %d -o && start \"\" %f")
("^dvi$" "." "yap -1 %dS %d")
("^pdf$" "." "cygstart %o")
("^html?$" "." "start \"\" %o"))
is enough.
Sunday, April 13, 2008
Making AucTeX launch the Windows Acrobat Reader
When I compile documents using AucTeX, I used to manually open and close the generated pdf by navigating to the file location and opening the file using Windows based Acrobat reader.
The Reader locks the file when in use, so if you recompile the document when the pdf is still open by the Reader, you'd get the "can't write to output file" error.
One workaround I used was, the cygwin based xpdf viewer which doesn't lock the file. But you'd have to refresh the file every time something changed, by hitting 'r' in the xpdf application.
The problem with the default AucTeX install was that it had the start "" %o as the entry for View which didn't do anything. Even though I don't use that feature, I thought, let's get this to point to Acrobat Reader and save it.
Turned out, you need to customise TeX-output-view-style. Setting it to
didn't work. Finally, one poster on the AucTeX mailing list give the answer which made it self evident. Since I was using cygwin, he suggested I use cygstart instead of start.
That worked like a charm and now my TeX-output-view-style looks like
The Reader locks the file when in use, so if you recompile the document when the pdf is still open by the Reader, you'd get the "can't write to output file" error.
One workaround I used was, the cygwin based xpdf viewer which doesn't lock the file. But you'd have to refresh the file every time something changed, by hitting 'r' in the xpdf application.
The problem with the default AucTeX install was that it had the start "" %o as the entry for View which didn't do anything. Even though I don't use that feature, I thought, let's get this to point to Acrobat Reader and save it.
Turned out, you need to customise TeX-output-view-style. Setting it to
start "acrord32" %o
acrord32 %o
didn't work. Finally, one poster on the AucTeX mailing list give the answer which made it self evident. Since I was using cygwin, he suggested I use cygstart instead of start.
That worked like a charm and now my TeX-output-view-style looks like
Its value is
(("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "dvips %d -o && start \"\" %f")
("^dvi$" "." "yap -1 %dS %d")
("^pdf$" "." "cygstart acrord32 %o")
("^html?$" "." "start \"\" %o"))
Subscribe to:
Posts (Atom)