Archive for the ‘Code’ Category

Emacs : eldoc mode and c-eldoc mode

May 22, 2010

eldoc mode as the name suggests provides documentation for Elisp files. This is a very useful and cool mode and shows the function signature in the mode-line when your cursor is on a particular function.  It also provides info on the variables. Check out the screen-shots below.

eldoc : Function signatures

eldoc : Variables description

To start eldoc mode, add the following to your .emacs file

;;Turn on documentation in elisp mode
(add-hook 'emacs-lisp-mode-hook
          '(lambda ()
	     (turn-on-eldoc-mode)))

c-eldoc mode is eldoc mode for c. It displays the arguments of C functions while one is programming.

c-eldoc

To add c-eldoc mode, get the latest c-eldoc.el, copy it in your load-path and then add then following to your .emacs file.

(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
Advertisements

Emacs : PKGBUILD mode

May 5, 2010

Discovered an amazing major mode for Emacs a few days back to edit PKGBUILDs. Essentially based on shell mode with the following extra bindings specific to PKGBUILDs.

C-c C-a pkgbuild-tar
C-c C-b pkgbuild-makepkg
C-c C-e pkgbuild-etags
C-c RET pkgbuild-update-md5sums-line
C-c C-r pkgbuild-increase-release-tag
C-c C-u pkgbuild-browse-url

I especially like pkgbuild-update-md5sums-line – very useful.

It also has some other cool functions. Check it out here.

My fork of the same is available here.

Hashbang #! and amarok1 on Arch

December 7, 2009

The #! at the start of bash, ruby, python scripts is called the hashbang. Its use with the Amarok install —

One or two days after writing the article about amarok1 installation on Arch, a new version of amarok1 with ruby1.9 support was uploaded. As most of the ruby scripts for amarok1 still work only with ruby1.8, I decided to keep my old version. Today, while I was looking through a few bash scripts, I realized that using #! in the needed ruby scripts was a better option. So, now I use the  AUR package and just change the hashbang lines in my scripts to point to ruby1.8 exec. If only I had realized this earlier 😛 😛

Anyways, more info about hashbang here.

wget : Add progress bar to non verbose mode

November 26, 2009

Check this bug report for the problem I had with default mode.

wget has four levels of verbosity which are described as below in its man page —

-d --debug
Turn on debug output, meaning various information important to the developers of Wget if it does not work properly. Your system administrator may have chosen to compile Wget without debug support, in which case -d will not work. Please note that compiling with debug support is always safe---Wget compiled with the debug support will not print any debug info unless requested with -d.

-q --quiet
Turn off Wget's output.

-v --verbose
Turn on verbose output, with all the available data. The default output is verbose.

-nv –no-verbose

Turn off verbose without being completely quiet (use -q for that), which means that error messages and basic information still get
printed.

The problem with these is that the verbose mode prints too much info, quiet prints nothing and non-verbose prints info which is not useful in any way.

(more…)

Emacs : Htmlize and WordPress Syntax Highlighter

October 2, 2009

In my previous post, I posted the perl script with syntax highlighting. I was able to get that code with syntax highlighting directly off the forum post. If you want to post random code with syntax highlighting, there are 3 options –

  1. Using plugins (generally not available for free)
  2. Using online generator such as those described here. (Usually give css code which cant be used in free mode of WordPress)
  3. Htmlize in Emacs 🙂

Emacs has an addon called “htmlize” which can be used to convert any file into an htmlized version. It provides 3 output types – css, inline-css and font. Emacs FTW again :D.

PS :: This is also available in the emacs-goodies.el packages in Debian and Ubuntu but the version of htmlize.el in those is outdated and does not work with Emacs 23.x

EDIT :: It seems that WordPress internally supports syntax highlighting with the use of SyntaxHighlighter. For more info check here. List of all the supported languages is here. For blogs other than WordPress, htmlize still seems a very good option.