<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Awhan Patnaik &#187; emacs</title>
	<atom:link href="http://awhan.wordpress.com/category/emacs/feed/" rel="self" type="application/rss+xml" />
	<link>http://awhan.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sun, 05 May 2013 11:54:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='awhan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Awhan Patnaik &#187; emacs</title>
		<link>http://awhan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://awhan.wordpress.com/osd.xml" title="Awhan Patnaik" />
	<atom:link rel='hub' href='http://awhan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>simultaneously edit matlab and octave files in emacs</title>
		<link>http://awhan.wordpress.com/2012/05/24/simultaneously-edit-matlab-and-octave-files-in-emacs/</link>
		<comments>http://awhan.wordpress.com/2012/05/24/simultaneously-edit-matlab-and-octave-files-in-emacs/#comments</comments>
		<pubDate>Wed, 23 May 2012 23:30:01 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[code editing]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[gnu octave]]></category>
		<category><![CDATA[text editing]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=445</guid>
		<description><![CDATA[the title of this post is misleading &#8230; i only talk about commenting and uncommenting region. this is a small tip for emacs users who want to edit matlab m-files and octave m-files without installing some major mode for editing matlab files. emacs already ships with a built in gnu octave mode and the true [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=445&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>the title of this post is misleading &#8230; i only talk about commenting and uncommenting region.</p>
<p>this is a small tip for emacs users who want to edit matlab m-files and octave m-files without installing some major mode for editing matlab files. emacs already ships with a built in gnu octave mode and the true hacker will use free software only. but i m no where near being a true hacker thus i often have to write some matlab stuff. i associate all .m files with the octave mode and i have the following line in my .emacs file to achieve that</p>
<pre class="brush: plain; title: ; notranslate">
(setq auto-mode-alist (cons '(&quot;\\.m$&quot; . octave-mode) auto-mode-alist))
</pre>
<p>the <em>major annoyance</em> is that matlab uses the &#8216;<strong>%</strong>&#8216; as the comment char while gnu octave uses &#8216;<strong>#</strong>&#8216;. so when editing m files in emacs i often include the following <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables" title="https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables">local file variables</a></p>
<pre class="brush: plain; title: ; notranslate">
% Local Variables:
% comment-start: &quot;%&quot;
% comment-column: 0
% End:
</pre>
<p>at the <strong>end</strong> of the m-file. these lines are treated as comments by the matlab interpreter due to the &#8216;%&#8217; prefix but emacs scans the file and reads these lines and now you can highlight text and use <strong>M-x comment-region</strong> or <strong>M-x uncomment-region</strong>. after adding the lines either kill the buffer and visit the file again or hit <strong>C-x C-v</strong> and then choose the same filename again. </p>
<p>there are probably many good features of the matlab editor but i have not used them much apart from the ability to run the current m file by hitting <strong>F5</strong> or setting and clearing breakpoints with mouse clicks. i do like the F5 thingy but i m sure a little bit of elisp can solve that problem. i m sure there are some good major modes for editing matlab files or integrating with matlab but i haven&#8217;t explored this area at all. </p>
<p>my emacs version is &#8220;GNU Emacs 23.4.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-04-12 on shirley.hoetzel.info&#8221;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/445/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=445&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2012/05/24/simultaneously-edit-matlab-and-octave-files-in-emacs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs breaks indentation for C++0x angle brackets</title>
		<link>http://awhan.wordpress.com/2011/01/07/emacs-breaks-indentation-for-c0x-angle-brackets/</link>
		<comments>http://awhan.wordpress.com/2011/01/07/emacs-breaks-indentation-for-c0x-angle-brackets/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 20:57:53 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[c++0x]]></category>
		<category><![CDATA[code indentation]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=363</guid>
		<description><![CDATA[i have always defined matrices of two dimensions as a vector of a vector container as follows however i recently learned that c++0x allows one to get rid of the extra space between the right angle brackets as in the following however emacs 23 breaks indentation when faced with this format i also use 3 [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=363&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>i have always defined matrices of two dimensions as a vector of a vector container as follows</p>
<pre class="brush: cpp; title: ; notranslate">
vector&lt; vector &lt;double&gt; &gt; v; // note the distance between the two right angle brakets just before v
</pre>
<p>however i recently learned that c++0x allows one to get rid of the extra space between the right angle brackets as in the following</p>
<pre class="brush: cpp; title: ; notranslate">
vector&lt; vector &lt;double&gt; &gt; v_old_style; 
vector&lt; vector &lt;double&gt;&gt; v_new_style; 
</pre>
<p>however emacs 23 breaks indentation when faced with this format<br />
<a href="http://awhan.files.wordpress.com/2011/01/emacsindentc0x.png"><img src="http://awhan.files.wordpress.com/2011/01/emacsindentc0x.png?w=500&#038;h=237" alt="" title="emacsIndentc++0x" width="500" height="237" class="aligncenter size-full wp-image-364" /></a></p>
<p>i also use 3 and 4 dimensional tensor like objects for which i would much like the following:</p>
<pre class="brush: cpp; title: ; notranslate">
vector &lt; vector &lt; vector &lt; vector &lt;double&gt; &gt; &gt; &gt; v1; // don't like it
vector&lt;vector&lt;vector&lt;vector&lt;double&gt;&gt;&gt;&gt; v2; // like this a lot 
</pre>
<p>for me at least the saving in horizontal space matters when i am comparing code side by side &#8230; also its quite easy to figure out the dimensionality of the tensor at one glance.</p>
<p>i don&#8217;t know how to fix this <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  help me please</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=363&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2011/01/07/emacs-breaks-indentation-for-c0x-angle-brackets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>

		<media:content url="http://awhan.files.wordpress.com/2011/01/emacsindentc0x.png" medium="image">
			<media:title type="html">emacsIndentc++0x</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs color theme</title>
		<link>http://awhan.wordpress.com/2010/07/04/emacs-color-theme/</link>
		<comments>http://awhan.wordpress.com/2010/07/04/emacs-color-theme/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 21:52:45 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[color theme tango]]></category>
		<category><![CDATA[elisp]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=296</guid>
		<description><![CDATA[been working with the default color scheme that comes with emacs on archlinux. most of the times i found that after long sessions and particularly at night my eyes would hurt looking at a white background. though i have an lcd screen but the white was too much. so i started looking for a dark [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=296&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>been working with the default color scheme that comes with emacs on archlinux. most of the times i found that after long sessions and particularly at night my eyes would hurt looking at a white background. though i have an lcd screen but the white was too much.</p>
<p>so i started looking for a dark color theme. first thing i tried was to install the <strong>emacs-color-theme</strong> package on archlinux. there r about 50 color themes in there.  most of them put me off so i started exploring various color themes. one of the themes that i liked is <a href="http://www.emacswiki.org/emacs/color-theme-tango.el">tango</a>. i m not saying it is the best as i have not explored a whole lot of choices but suffice it to say that looking at the screen with the tango theme hurt my eyes less than the default theme.</p>
<p>Attempt 0 &#8212;&gt; failure <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>0) put the <strong>color-theme-tango.el</strong> file some where so that emacs can find it. i simply put it in the <strong>.emacs.d</strong> directory of my $HOME.</p>
<p>1) add the following lines in ur .emacs</p>
<pre class="brush: plain; title: ; notranslate">
;; add the .emacs.d directory to emacs search path, since i put the .el file in there
(add-to-list 'load-path &quot;/home/m/.emacs.d&quot;)
(require 'color-theme)
(color-theme-tango)</pre>
<p>2) save the .emacs</p>
<p>unfortunately on restarting emacs i encounted the following problem</p>
<pre class="brush: plain; title: ; notranslate">
Symbol's function definition is void: color-theme-tango
</pre>
<p>i do not know enough ELISP to make sense of that. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Attempt 1 &#8212;&gt; Success  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />     (note the sad face!)</p>
<p>0) put the color-theme-tango.el file ANYWHERE u feel like . i simply put it in $HOME/.emacs.d/myThemes directory<br />
1)  add the following lines in ur .emacs</p>
<pre class="brush: plain; title: ; notranslate">
(require 'color-theme)
(load &quot;/home/m/.emacs.d/myThemes/color-theme-tango.el&quot;)
(color-theme-tango)
</pre>
<p>2) save the .emacs, close and restart emacs</p>
<p>that worked finally and my eyes could breathe easy. the final result is as follows<br />
<a href="http://awhan.files.wordpress.com/2010/07/tango.png"><img class="aligncenter size-full wp-image-297" title="tango" src="http://awhan.files.wordpress.com/2010/07/tango.png?w=500" alt=""   /></a></p>
<p>though i got the theme working there are somethings i do not understand<br />
0) the color theme page at emacswiki does not give any instruction of the sort &#8220;(load &#8220;path/to/file.el&#8221;)&#8221; so i must be missing something.<br />
1) even when i added the file containing directories to the load-path in emacs, the files could not be found. again i must be doing something wrong.<br />
2) what is the meaning of the error/warning message that i got?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/296/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=296&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/07/04/emacs-color-theme/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>

		<media:content url="http://awhan.files.wordpress.com/2010/07/tango.png" medium="image">
			<media:title type="html">tango</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs maximized</title>
		<link>http://awhan.wordpress.com/2010/06/27/emacs-maximized/</link>
		<comments>http://awhan.wordpress.com/2010/06/27/emacs-maximized/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 01:40:55 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=290</guid>
		<description><![CDATA[back when i was on ubuntu hardy heron i used the following in my .emacs to maximize the emacs window on startup now that i am on archlinux with emacs 23.2.1 i follow a different strategy i have defined the following function in my .bashrc the reason i defined a function and not an alias [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=290&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>back when i was on ubuntu hardy heron i used the following in my .emacs to maximize the emacs window on startup</p>
<pre class="brush: plain; title: ; notranslate">
;;i tried the following with ``emacs -nw&quot; and it does not work
 (defun toggle-fullscreen ()
   (interactive)
   (x-send-client-message nil 0 nil &quot;_NET_WM_STATE&quot; 32
 	    		 '(2 &quot;_NET_WM_STATE_MAXIMIZED_VERT&quot; 0))
   (x-send-client-message nil 0 nil &quot;_NET_WM_STATE&quot; 32
 			 '(2 &quot;_NET_WM_STATE_MAXIMIZED_HORZ&quot; 0))
   )
(toggle-fullscreen)
</pre>
<p>now that i am on archlinux with emacs 23.2.1 i follow a different strategy</p>
<p>i have defined the following function in my .bashrc</p>
<pre class="brush: plain; title: ; notranslate">
function e()
{
    # i was advised to not use $*
    emacs --maximized &quot;$@&quot; &amp;
}
</pre>
<p>the reason i defined a function and not an alias is so that i can use the &amp; at the end.</p>
<p>this works great.</p>
<p>i just wanted to make this post for reference as i m modifying my .emacs</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=290&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/06/27/emacs-maximized/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>install yasnippet on archlinux</title>
		<link>http://awhan.wordpress.com/2010/06/19/install-yasnippet-on-archlinux/</link>
		<comments>http://awhan.wordpress.com/2010/06/19/install-yasnippet-on-archlinux/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 17:09:52 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[yasnippet]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=278</guid>
		<description><![CDATA[yasnippet is not available in the archlinux repos so we will install it from the AUR first go to AUR home and search for yasnippet &#8230; u will get the following page http://aur.archlinux.org/packages.php?ID=18440 download the tarball from that page .. in my case the link to the tarball was http://aur.archlinux.org/packages/emacs-yasnippet/emacs-yasnippet.tar.gz put the tarball in a [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=278&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>yasnippet is not available in the archlinux repos so we will install it from the AUR</p>
<p>first go to AUR home and search for yasnippet &#8230; u will get the following page</p>
<p><a href="http://aur.archlinux.org/packages.php?ID=18440" rel="nofollow">http://aur.archlinux.org/packages.php?ID=18440</a></p>
<p>download the tarball from that page .. in my case the link to the tarball was</p>
<p><a href="http://aur.archlinux.org/packages/emacs-yasnippet/emacs-yasnippet.tar.gz" rel="nofollow">http://aur.archlinux.org/packages/emacs-yasnippet/emacs-yasnippet.tar.gz</a></p>
<p>put the tarball in a convenient location and extract it to get an <strong>emacs-yasnippet</strong> directory. within that folder you will find 2 files: PKGBUILD and yasnippet.install</p>
<p>now from within the emacs-yasnippet directory run the following command</p>
<pre class="brush: plain; title: ; notranslate">
makepkg -s

</pre>
<p>the -s flag will ensure that all dependencies are installed first.</p>
<p>when i ran the command i got the following error</p>
<blockquote><p>$ makepkg -s<br />
==&gt; ERROR: Fakeroot must be installed if using the &#8216;fakeroot&#8217; option<br />
in the BUILDENV array in /etc/makepkg.conf.</p></blockquote>
<p>which means that the <strong>fakeroot</strong> program is missing &#8230;<br />
some more digging told me that i might be missing the <strong>base-devel</strong> group of packages</p>
<p>so i first have to install it</p>
<pre class="brush: plain; title: ; notranslate">
sudo pacman -Ss base-devel
</pre>
<p>this will install all the packages needed for building software.</p>
<p>now let me try running makepkg again &#8230;</p>
<p>makepkg -s</p>
<p>&#8230;ok it was successful this time and now the folder contains the following files and folders</p>
<blockquote><p>emacs-yasnippet-0.6.1c-2-any.pkg.tar.xz  pkg  PKGBUILD  src  yasnippet-0.6.1c.tar.bz2  yasnippet.install</p></blockquote>
<p>all is fine now.. we will simply install now using pacman</p>
<pre class="brush: plain; title: ; notranslate">
sudo pacman -U emacs-yasnippet-0.6.1c-2-any.pkg.tar.xz
</pre>
<p>that is it you are done &#8230;</p>
<p>of course you must add the following in your .emacs to use yasnippet</p>
<pre class="brush: plain; title: ; notranslate">
(add-to-list 'load-path &quot;/usr/share/emacs/site-lisp/yas&quot;)
(require 'yasnippet)
(yas/initialize)
(yas/load-directory &quot;/usr/share/emacs/site-lisp/yas/snippets&quot;)
</pre>
<ol>
<li><a href="http://code.google.com/p/yasnippet/">yasnippet</a></li>
<li><a href="http://aur.archlinux.org/">AUR</a></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/278/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=278&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/06/19/install-yasnippet-on-archlinux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs c++ tags</title>
		<link>http://awhan.wordpress.com/2010/03/30/emacs-c-tags/</link>
		<comments>http://awhan.wordpress.com/2010/03/30/emacs-c-tags/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 23:31:26 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=247</guid>
		<description><![CDATA[source code navigation using tags is a lifesaver in large projects &#8230; i have been using the system for sometime but was vexed with a problem for a long time.  i m on ubuntu 8.04 which has the exuberant ctags package available.  my makefiles have a phony target called `tags&#8217; that generate the TAGS file [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=247&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>source code navigation using tags is a lifesaver in large projects &#8230; i have been using the system for sometime but was vexed with a problem for a long time.  i m on <strong>ubuntu 8.04</strong> which has the <strong>exuberant ctags</strong> package available.  my makefiles have a phony target called `tags&#8217; that generate the TAGS file to use in emacs. this is how i generate the TAGS file by writing make tags at the command line</p>
<pre class="brush: plain; title: ; notranslate">

tags:

find -L $(srcDirs) -name '*.cpp' -o -name '*.h' |  etags -L -

</pre>
<p>when ever i searched for a tag in emacs using<strong> M-.</strong> i was always taken to the function definition in the .cpp files (source files) but never to the .h files (header files)</p>
<p>the reason for this is two fold</p>
<ul>
<li>i practice separation of interface and implementation i.e. the function declaration and function definition are in separate files viz. .h files and .cpp files.</li>
<li>i did not know the use of &#8211;&lt;LANG&gt;-kinds=[+|-]kinds option available with ctags</li>
</ul>
<p>&#8211;&lt;LANG&gt;-kinds=[+|-]kinds is then the key to the solution of this vexing problem. since the language i use is c++ then LANG becomes c++, that is &#8211;c++-kinds=[+|-]kinds while kinds for c++ could be any of the following</p>
<blockquote><p>
c  classes<br />
d  macro definitions<br />
e  enumerators (values inside an enumeration)<br />
f  function definitions<br />
g  enumeration names<br />
l  local variables [off]<br />
m  class, struct, and union members<br />
n  namespaces<br />
p  function prototypes [off]<br />
s  structure names<br />
t  typedefs<br />
u  union names<br />
v  variable definitions<br />
x  external and forward variable declarations [off]</p></blockquote>
<p>notice that p (function prototypes) is off by default &#8230; which means that etags was skipping over the function declaration in header files&#8230; so i could not go to them when searching for a tag. so the solution to my problem is that i should generate tags using the following:</p>
<pre class="brush: plain; title: ; notranslate">

tags:

find -L $(srcDirs) -name '*.cpp' -o -name '*.h' |  etags --c++kinds=+p   -L -

</pre>
<p>+p simply turns on (+) the tagging of funtion prototypes (p) .</p>
<p>that&#8217;s it and happy days r here!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=247&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/03/30/emacs-c-tags/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs confine search and/or replace within a c++ function</title>
		<link>http://awhan.wordpress.com/2010/03/10/emacs-confine-search-andor-replace-within-a-c-function/</link>
		<comments>http://awhan.wordpress.com/2010/03/10/emacs-confine-search-andor-replace-within-a-c-function/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:20:36 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=234</guid>
		<description><![CDATA[in a typical c++ file i have many functions and many a times i needed to search a keyword/variable or carry out a search and replace operation &#8230; however it becomes very confusing if multiple functions exist that use the same variable names. often times i keep hitting C-s and i never can know if [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=234&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>in a typical c++ file i have many functions and many a times i needed to search a keyword/variable or carry out a search and replace operation &#8230; however it becomes very confusing if multiple functions exist that use the same variable names.</p>
<p>often times i keep hitting<strong> C-s</strong> and i never can know if i m still within the function i started in or ventured in to a different function altogether &#8230; this is more confusing since i use long functions spanning many screenfuls of code <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>a good thing that i discovered is <strong>which-function-mode</strong> that i talked about <a href="http://awhan.wordpress.com/2010/02/27/emacs-which-c-function-am-i-in/">here</a> &#8230; which can be helpful but one has to always keep a watch on the modeline &#8230;</p>
<p>but i wanted to confine the search or  search and replace within the scope of a function definition &#8230; turns out the all powerful emacs can do that and it does it well i think <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>first &#8230;</p>
<p>emacs has the ability to make every thing else invisible &#8230; everything else but your region of interest &#8230; the stuff won&#8217;t disappear it will simply be not visible&#8230; of course u can make it visible again at the click of a few key chords &#8230; here is how you do it</p>
<p>first select the region of interest if you simply want to select the entire function simply hit the following keychord within the body of function definition</p>
<pre class="brush: plain; title: ; notranslate">

C-M-h

</pre>
<p>then to make everything else disappear hit the following</p>
<pre class="brush: plain; title: ; notranslate">

C-x n n

</pre>
<p>you might have to first all the usage of this if you haven&#8217;t used this before.. apparently it confuses some beginners so they disable it by default and warn u on its first use.  onwards now &#8230;</p>
<p>now that everything else has become invisible&#8230; the search and replace commands miraculously behave as if the other stuff does not exist &#8230; buffer movement keys also behave as if the selected region alone exists in the buffer &#8230; lucky for us this is precisely what we wanted &#8230; after you are done with search and or replace simply hit the following key chord</p>
<pre class="brush: plain; title: ; notranslate">

C-x n w

</pre>
<p>and everything else will come back !!!</p>
<p>of course its not limited to c++ files alone</p>
<p><a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html">http://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/234/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=234&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/03/10/emacs-confine-search-andor-replace-within-a-c-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs cpu hog</title>
		<link>http://awhan.wordpress.com/2010/03/06/emacs-cpu-hog/</link>
		<comments>http://awhan.wordpress.com/2010/03/06/emacs-cpu-hog/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 09:12:10 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[emacs]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=224</guid>
		<description><![CDATA[i m on ubuntu 8.04 ( hardy heron ) and every once in a while emacs freezes &#8230; i use htop to find out that emacs and X are hogging up cpu cycles &#8230; when i kill emacs it all returns to normal. some times i see the same thing happening when i have firefox [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=224&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>i m on ubuntu 8.04 ( hardy heron ) and every once in a while emacs freezes &#8230; i use htop to find out that emacs and X are hogging up cpu cycles &#8230; when i kill emacs it all returns to normal.</p>
<p><a href="http://awhan.files.wordpress.com/2010/03/emacscpuhog.png"><img class="aligncenter size-full wp-image-225" title="emacsCpuHog" src="http://awhan.files.wordpress.com/2010/03/emacscpuhog.png?w=500" alt=""   /></a></p>
<p>some times i see the same thing happening when i have firefox open but this is quite rare &#8230; this leads me to believe that probably emacs alone may not be the culprit. but how can i find out exactly what is causing the problem ?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/224/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=224&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/03/06/emacs-cpu-hog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>

		<media:content url="http://awhan.files.wordpress.com/2010/03/emacscpuhog.png" medium="image">
			<media:title type="html">emacsCpuHog</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs find next occurrence of tag OR &#8220;C-u M-.&#8221; made easier to type</title>
		<link>http://awhan.wordpress.com/2010/03/03/emacs-find-next-occurrence-of-tag-or-c-u-m-made-easier-to-type/</link>
		<comments>http://awhan.wordpress.com/2010/03/03/emacs-find-next-occurrence-of-tag-or-c-u-m-made-easier-to-type/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 07:00:58 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=220</guid>
		<description><![CDATA[in emacs one may use tags to navigate source code. i use etags to generate a tags list for my source code tree and then to navigate one simply needs to hit which stands for now to find the next occurance of the same tag one needs to hit several times in succession to navigate [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=220&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>in emacs one may use tags to navigate source code. i use <strong>etags</strong> to generate a tags list for my source code tree and then to navigate one simply needs to hit</p>
<pre class="brush: plain; title: ; notranslate">

M-.

</pre>
<p>which stands for</p>
<pre class="brush: plain; title: ; notranslate">

find-tag

</pre>
<p>now to find the next occurance of the same tag one needs to hit</p>
<pre class="brush: plain; title: ; notranslate">

C-u M-.

</pre>
<p>several times in succession to navigate to all the occurances of the tag. typing that key chord is very discomforting and annoying. one has to move the hands away from the home row and then contort the digits to execute the key chord. in an earlier attempt to make life easier i mapped the Control key to the CapsLock key on the pc keyboard, but that did not offer much relief so i thought of biding an usused key to this key chord.</p>
<p>being an inexperienced noob and after querrying the WWW for many related searches i found a working solution which is as follows</p>
<p>edit your <strong>.emacs</strong> file to include the following line</p>
<pre class="brush: plain; title: ; notranslate">

(global-set-key  [f9]   (read-kbd-macro &quot;C-u M-.&quot;))

</pre>
<p>this basically maps the function key F9 to the culprit key chord in question.</p>
<p>inspiration/hints for the above hack comes from the following page</p>
<p><a href="http://jmjeong.com/wikix/file/Emacs/key-bindings_el.txt">http://jmjeong.com/wikix/file/Emacs/key-bindings_el.txt</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/220/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=220&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/03/03/emacs-find-next-occurrence-of-tag-or-c-u-m-made-easier-to-type/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
		<item>
		<title>emacs which c++ function am i in ?</title>
		<link>http://awhan.wordpress.com/2010/02/27/emacs-which-c-function-am-i-in/</link>
		<comments>http://awhan.wordpress.com/2010/02/27/emacs-which-c-function-am-i-in/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 06:36:46 +0000</pubDate>
		<dc:creator>awhan</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://awhan.wordpress.com/?p=217</guid>
		<description><![CDATA[some time when there are a lot of functions in a c++ file, one may get lost trying to figure out which funtion the current line belongs to.  the problem is intensified when the function spans more than a couple screen fuls. and then there is an occasional C-s ( incremental search ) which will [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=217&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>some time when there are a lot of functions in a c++ file, one may get lost trying to figure out which funtion the current line belongs to.  the problem is intensified when the function spans more than a couple screen fuls. and then there is an occasional <strong>C-s</strong> ( incremental search ) which will lead you to many matches making you forget where you were and confusing you about where you currently are.</p>
<p>for a long time now i wished where was way where emacs could tell me the current function i was in, turns out that emacs does have such a feature:</p>
<blockquote><p>which-function-mode</p></blockquote>
<p>hit</p>
<pre class="brush: plain; title: ; notranslate">

M-x describe-function

</pre>
<p>and then type in</p>
<p>which-function-mode</p>
<p>to learn more about it.</p>
<p>to turn on globally just add the following in your .emacs</p>
<pre class="brush: plain; title: ; notranslate">

(which-function-mode 1)

</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/awhan.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/awhan.wordpress.com/217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=awhan.wordpress.com&#038;blog=6706122&#038;post=217&#038;subd=awhan&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://awhan.wordpress.com/2010/02/27/emacs-which-c-function-am-i-in/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13bd5c4b43b158bb12be3d8f80ede75d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">awhan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
