Wishing all my readers a joyous and prosperous new year.
Postings on living in an Emacs world. Posts will be mostly on using Emacs, related functions and tools.
Ads by Google
Friday, December 26, 2008
Thursday, December 25, 2008
Generating Automatic File headers
You know how you get nagged to document your code? What the file does, who created it, when was it last changed and a history log; all that the QC guy insists that you plug in?
Well, you make an attempt at it initially, and then laziness takes over; you start to copy the header from an existing file to a new one which comes with it's own set of headaches. You have to correct all the previous references to the correct file name, change the history etc.
There is an Emacs package called header.el that allows you to create the file header and also automatically update certain parts of the header every time you save. There are templates for common classes of file types and the headers generated are self explanatory.
Download the above file,byte-compile it and put it in a place where Emacs can find it. Add the following to your .emacs.
(require 'header)
A couple of screenshots should make it clear how useful it can be. Suppose I create a new file called ccc.sh and invoke M-x make-header.
This will create a template for shell scripts as shown below. Note that the user name is picked up from user-full-name which needs to be set in your .emacs.
The moment I save the file, the "Last Modified" lines and the update count are automatically updated and are done every time the file is saved.
Well, you'd obviously like to put in some revision history and that is done by M-x make-revision which creates a history section as shown
The commentary inside header.el has more information on customising these features, especially copyright notices and header design to suit your organisation's standards. From the header.el source file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Define the individual header elements. THESE ARE THE BUILDING BLOCKS
;; used to construct a site specific header. You may add your own
;; functions either in this file or in your .emacs file. The variable
;; make-header-hooks specifies the functions that will actually be called.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
And user customisable options such as
;; This file adds support for the creation and automatic maintenence of file
;; headers such as the one above.
;; User Commands:
;; M-x make-header
;; M-x make-revision
;; M-x make-divisor
;; M-x make-box-comment
;; Customizer commands
;; register-file-header-action
;; Customizer variables
;; header-copyright-notice
;; make-header-hooks
It's a good idea to put all the changes into your .emacs instead of editing the source elisp file.
One other note: The emacswiki site has a section on AutomaticFileHeaders that outlines some improvements over header.el and available as header2.el done by Drew Adams. You may want to try that too, though I haven't tried the new version.
Well, you make an attempt at it initially, and then laziness takes over; you start to copy the header from an existing file to a new one which comes with it's own set of headaches. You have to correct all the previous references to the correct file name, change the history etc.
There is an Emacs package called header.el that allows you to create the file header and also automatically update certain parts of the header every time you save. There are templates for common classes of file types and the headers generated are self explanatory.
Download the above file,byte-compile it and put it in a place where Emacs can find it. Add the following to your .emacs.
(require 'header)
A couple of screenshots should make it clear how useful it can be. Suppose I create a new file called ccc.sh and invoke M-x make-header.
This will create a template for shell scripts as shown below. Note that the user name is picked up from user-full-name which needs to be set in your .emacs.
The moment I save the file, the "Last Modified" lines and the update count are automatically updated and are done every time the file is saved.
Well, you'd obviously like to put in some revision history and that is done by M-x make-revision which creates a history section as shown
The commentary inside header.el has more information on customising these features, especially copyright notices and header design to suit your organisation's standards. From the header.el source file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Define the individual header elements. THESE ARE THE BUILDING BLOCKS
;; used to construct a site specific header. You may add your own
;; functions either in this file or in your .emacs file. The variable
;; make-header-hooks specifies the functions that will actually be called.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
And user customisable options such as
;; This file adds support for the creation and automatic maintenence of file
;; headers such as the one above.
;; User Commands:
;; M-x make-header
;; M-x make-revision
;; M-x make-divisor
;; M-x make-box-comment
;; Customizer commands
;; register-file-header-action
;; Customizer variables
;; header-copyright-notice
;; make-header-hooks
It's a good idea to put all the changes into your .emacs instead of editing the source elisp file.
One other note: The emacswiki site has a section on AutomaticFileHeaders that outlines some improvements over header.el and available as header2.el done by Drew Adams. You may want to try that too, though I haven't tried the new version.
Sunday, December 21, 2008
Footnote mode
Those familiar with LaTeX will understand footnotes and how they are generated when the LaTeX document is compiled. Emacs too, comes with a footnote package that sort of imitates the LaTeX style. This can be used in any text based document whether it is emails or plain articles.
Footnotes mode is bundled with Emacs, so it's invoked by M-x footnote-mode. It is a minor mode which is really handy especially when you don't want your text to be marred by long urls, lengthy explanations which disrupt the flow of thought. I find it useful by simply adding the dummy footnotes for key words and the like and then writing the explanation at the bottom as I complete the article.
A screen shot of how it works will
While this adds some nice professional look to your text based email, there are some minor issues to be borne in mind. The numbering is not preserved between sessions i.e. when the file is re-opened, numbering will start again from 1. This might not be ideal though it is easy to work around with, by increasing the sequence till it matches the current valid running number.
Or as the wiki pages go,there is a patch to fix that. But that is not yet part of the mainline Emacs 23, so it's left to you to remember to upgrade whenever Emacs is upgraded.
Footnotes mode is bundled with Emacs, so it's invoked by M-x footnote-mode. It is a minor mode which is really handy especially when you don't want your text to be marred by long urls, lengthy explanations which disrupt the flow of thought. I find it useful by simply adding the dummy footnotes for key words and the like and then writing the explanation at the bottom as I complete the article.
A screen shot of how it works will
While this adds some nice professional look to your text based email, there are some minor issues to be borne in mind. The numbering is not preserved between sessions i.e. when the file is re-opened, numbering will start again from 1. This might not be ideal though it is easy to work around with, by increasing the sequence till it matches the current valid running number.
Or as the wiki pages go,there is a patch to fix that. But that is not yet part of the mainline Emacs 23, so it's left to you to remember to upgrade whenever Emacs is upgraded.
Tuesday, December 16, 2008
How to make Gnus behave a little like Pine
This just up on the Emacswiki. A page describing how to make your Gnus behave more like Pine.
Quite why you'd want to do that is beyond me as they're different as chalk and cheese. Well, apart from being text based email clients, that is.
Still, whatever floats your boat.
Quite why you'd want to do that is beyond me as they're different as chalk and cheese. Well, apart from being text based email clients, that is.
Still, whatever floats your boat.
Friday, December 12, 2008
How to get information out of a subshell?
The above topic seems to be a pretty common request on the comp.unix.shell newsgroup. It was for me too, when I was learning shell programming. Sooner or later, as a noob, you run into that code fragment that doesn't store the values you were sure were getting generated. Heck, look at all the echo statements, you put in!
It seems to take a bit programming experience to figure out these subshells, processes, command substitution and the like. The more code you write, the more likely you are going to get into situations where such features are absolutely required for your code to work.
This thread here provides several ways to do it by other coders.
It seems to take a bit programming experience to figure out these subshells, processes, command substitution and the like. The more code you write, the more likely you are going to get into situations where such features are absolutely required for your code to work.
This thread here provides several ways to do it by other coders.
Tuesday, December 9, 2008
PDFcomment: A userfriendly interface to \pdfannot
Just saw this new package,PDFcomment on the ctan-ann mailing list. The \pdfannot command is used to add comments to your PDF file when generated through pdflatex. This has varying degrees of support depending on the PDF viewer and the version of the viewer i.e. you might not see the comments at all if your viewer does not support it; Rest assured that the PDF file is still the same.
And this style file is a decent interface (warning PDF file) to the underlying pdfannot command. Note that while one can add comments through PDFLaTeX, others receiving it cannot add more comments. Unless explicit permissions are set on the PDF file. Which pdftex does not support and needs to be done using some other external tools.
The last time I checked, there were some legal issues in changing document permissions of an already created PDF file. Unfortunately, can't find where I saw that and I could be completely wrong about it. I believe this AREnable tool probably would help though I've never used it.
And this style file is a decent interface (warning PDF file) to the underlying pdfannot command. Note that while one can add comments through PDFLaTeX, others receiving it cannot add more comments. Unless explicit permissions are set on the PDF file. Which pdftex does not support and needs to be done using some other external tools.
The last time I checked, there were some legal issues in changing document permissions of an already created PDF file. Unfortunately, can't find where I saw that and I could be completely wrong about it. I believe this AREnable tool probably would help though I've never used it.
Friday, December 5, 2008
Mouse avoidance mode: addressing minor irritants while working
You know the number of times you have to nudge the mouse, just to get the mouse pointer out of the way? Irritatingly, right over the last letter and cursor when you have writer's block and staring blankly at the screen?
Well, Emacs has a minor mode to fix that too. erm....the mouse pointer, not the empty thought.
It's invoked as M-x mouse-avoidance-mode and gives you several options of how the mouse should behave when you call the function. From the doc string
* banish: Move the mouse to the upper-right corner on any keypress.
* exile: Move the mouse to the corner only if the cursor gets too close, and allow it to return once the cursor is out of the way.
* jump: If the cursor gets too close to the mouse, displace the mouse a random distance & direction.
* animate: As `jump', but shows steps along the way for illusion of motion.
* cat-and-mouse: Same as `animate'.
* proteus: As `animate', but changes the shape of the mouse pointer too.
You can repeatedly chose from the different options to see what behaviour you like. All you have to do is to bring the mouse close to point or where you are typing to see it move away.
Works beautifully without any noticeable disturbance to your typing.
Nice.
Well, Emacs has a minor mode to fix that too. erm....the mouse pointer, not the empty thought.
It's invoked as M-x mouse-avoidance-mode and gives you several options of how the mouse should behave when you call the function. From the doc string
* banish: Move the mouse to the upper-right corner on any keypress.
* exile: Move the mouse to the corner only if the cursor gets too close, and allow it to return once the cursor is out of the way.
* jump: If the cursor gets too close to the mouse, displace the mouse a random distance & direction.
* animate: As `jump', but shows steps along the way for illusion of motion.
* cat-and-mouse: Same as `animate'.
* proteus: As `animate', but changes the shape of the mouse pointer too.
You can repeatedly chose from the different options to see what behaviour you like. All you have to do is to bring the mouse close to point or where you are typing to see it move away.
Works beautifully without any noticeable disturbance to your typing.
Nice.
Thursday, December 4, 2008
OXML plugin for Firefox
Not sure where this heading but Microsoft has released an Open XML document viewer plugin for Firefox.
The plugin itself can be downloaded here.
If users don't know that it is a Microsoft standard document format, would they adopt it without reservations? The plugin is not downloadable from Microsoft's support pages too. I can't think of a reason why they'd want to release this plugin; it's not that they've cared before that their documents have to be read from different document editors or viewers.
What gives?
The plugin itself can be downloaded here.
If users don't know that it is a Microsoft standard document format, would they adopt it without reservations? The plugin is not downloadable from Microsoft's support pages too. I can't think of a reason why they'd want to release this plugin; it's not that they've cared before that their documents have to be read from different document editors or viewers.
What gives?
Subscribe to:
Posts (Atom)