I wanted my name and email address to appear in the top of the page every time I create a new python file in Emacs. So here’s what I did to achieve that.
First of all create a folder called templates in the .emacs.d directory (the .emacs.d directory is located in your home directory. If it does not exist, just create the directory ). Then create a file named template.py in that directory. And add the text you want to be included when you create a new python file. An example can be shown as follows.
#Name: This Is My Name
Then open the .emacs file in your home directory (if this doesn’t exist, simply create an empty file named .emacs). Then add the following content to the bottom of the .emcas.
;To load python templates
(add-hook 'find-file-hooks 'maybe-load-template)
(defun maybe-load-template ()
(string-match "\\.py$" (buffer-file-name))
(eq 1 (point-max)))
(Use the ‘Lisp’ link above to copy the code).
That’s all…!. Now when ever you create a new python file using Emacs these header info will appear!.
As you might have observed this trick can be extended to other file types by changing the .py extension in the (insert-file “~/.emacs.d/templates/template.py”) line and creating a relevant template in the templates folder.
Also there are more advanced ways to achieve the same with more functionality in http://www.emacswiki.org/emacs/AutomaticFileHeaders
This is a script I wrote long time ago.It will load the last used status when Empathy restarts or when one of the accounts of the user comes online. This functionality was not available in Empathy at the time I wrote this script. Every time I restart Empathy, its chat status was reset to “Available”. But now it seems that the new Empathy versions has the capability to remember the last used chat status (whether it was “Available”, “Busy”, “Away”, or “Invisible”). But still Empathy cannot remember the chat status message that was used in the last time. This script adds all this functionality to Empathy.
How to use this:
(These guidelines are for Ubuntu 11.04 . But procedure will be lot common
in other Linux flavours too)
0) Get the code from https://github.com/ishanthilina/saveMyStatus
1).Create a folder named “.scripts” in the home directory. Copy this script to that folder.
2).Go to Startup Application Preferences (search for “startup” in dashboard).
4).Give any Name you like.
5).In Command, click on Browse and select your script from the file browser (which is in
6).Add a comment if you like.
Now the script will run from the next time you login to the computer. Have fun. And don’t forget to give me feedback 🙂
Folderview screenlet is one of the screenlets that I have found very useful. But it doesn’t function correctly with the new python version (python 2.7). When the option is selected to view the properties dialog it gives the following exception.
Traceback (most recent call last):
File “/usr/lib/python2.7/site-packages/screenlets/__init__.py”, line 1913, in button_press
File “/usr/lib/python2.7/site-packages/screenlets/__init__.py”, line 2119, in menuitem_callback
File “/usr/lib/python2.7/site-packages/screenlets/__init__.py”, line 1570, in show_settings_dialog
se.set_info(self.__name__, glib.markup_escape_text(self.__desc__), ‘(c) ‘ + glib.markup_escape_text(self.__author__),
TypeError: glib.markup_escape_text() argument 1 must be string or read-only buffer, not None
It seems that the variable __desc__ is not set when calling the glib.markup_escape_text() method. So until some geek comes and fix this bug, we can use the following method to overcome this burden. (You’ll be able to follow the same procedure if you are getting this error for some other screenlet too 😀 )
- Open __init__.py in /usr/lib/python2.7/site-packages/screenlets with root privileges.
- Find the line se.set_info(self.__name__, glib.markup_escape_text(self.__desc__), ‘(c) ‘ + glib.markup_escape_text(self.__author__) . This should approximately be in the line 1570.
- Add the following code segment before that line.
if not self.__desc__:
self.__desc__=’Description not set’
(keep in mind that python is sensitive to indentations).
- Save and restart the screenlet.
Congratulations…! You have fixed a bug in a very naive way….! .