<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://nolan.eakins.net" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Nolan&#039;s Corner - Emacs</title>
 <link>http://nolan.eakins.net/taxonomy/term/27/0</link>
 <description>Emacs, the bloated text editor that I love</description>
 <language>en</language>
<item>
 <title>Emacs Function of the Day: propertize</title>
 <link>http://nolan.eakins.net/node/294</link>
 <description>&lt;p&gt;Today&#039;s Emacs function of the day is &lt;code&gt;propertize&lt;/code&gt;. It allows you to format text in ways that are plain pretty. As an example, here&#039;s code to insert &quot;&lt;span style=&quot;background: #005000; color: #00ff00;&quot;&gt;Gah! I&#039;m green!&lt;/span&gt;&quot; into a buffer:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre&gt;
(insert (&lt;b&gt;propertize&lt;/b&gt; &quot;Gah! I&#039;m green!&quot; &#039;face &#039;(:foreground &quot;#00ff00&quot; :background &quot;#005000&quot;)))
&lt;/pre&gt;
&lt;/blockquote&gt;</description>
 <comments>http://nolan.eakins.net/node/294#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/27">Emacs</category>
 <pubDate>Sun, 09 Jul 2006 21:23:12 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">294 at http://nolan.eakins.net</guid>
</item>
<item>
 <title>Random Emacs Functions</title>
 <link>http://nolan.eakins.net/node/208</link>
 <description>&lt;p&gt;I created some functions for Emacs because I really didn&#039;t want to do this stuff by hand. I have here four functions: &lt;code&gt;count-occurences&lt;/code&gt;, &lt;code&gt;line-empty?&lt;/code&gt;, &lt;code&gt;unfill-region&lt;/code&gt;, &lt;code&gt;unfill-buffer&lt;/code&gt;. You can either read the rest of this post, or &lt;a href=&quot;/cgi-system/drupal_files/sneakins-helpers.el&quot;&gt;click here to get the file&lt;/a&gt;.&lt;/p&gt;
&lt;!--break--&gt;

&lt;p&gt;Here&#039;s the code for each:&lt;/p&gt;
&lt;h2&gt;count-occurences&lt;/h2&gt;
&lt;pre&gt;
(defun count-occurences (string)
  &quot;Counts the number of occurences of STRING in the buffer.&quot;
  (interactive (list (read-string &quot;Count: &quot;)))
  (let ((point (point))
	(counter 0))
    (beginning-of-buffer)
    (loop with pos = t
	  until (not (search-forward string (point-max) t))
	  do (incf counter))
    (goto-char point)
    (message (format &quot;%d occurences&quot; counter))
    counter))
&lt;/pre&gt;

&lt;h2&gt;line-empty?&lt;/h2&gt;
&lt;pre&gt;
(defun line-empty? ()
  &quot;Returns true if the current line is empty.&quot;
  (eq (line-beginning-position) (line-end-position)))
&lt;/pre&gt;

&lt;h2&gt;unfill-region&lt;/h2&gt;
&lt;pre&gt;
(defun unfill-region (min max)
  &quot;Joins the lines in the paragraphs inside a
region defined by MIN and MAX. If this is called
interactively then the mark and point are used to
define the region.&quot;
  (interactive (list (mark)
		     (point)))
  (if (&gt; min max)
      (let ((temp min))
	(setq min max)
	(setq max temp)))
  (goto-char min)
  (message (format &quot;%d %d&quot; min max))
  (let ((empty nil))
    (message &quot;Unfilling...&quot;)
    (loop with end = min
	  always (&lt; end max)
	  do
	  (setq end (line-end-position))
	  (setq empty (line-empty?))
	  (next-line 1)
	  (if (not empty)
	      (if (not (line-empty?))
		  (join-line))))
    (message &quot;Unfilled&quot;)))
&lt;/pre&gt;

&lt;h2&gt;unfill-buffer&lt;/h2&gt;
&lt;pre&gt;
(defun unfill-buffer ()
  &quot;Joins the lines of all the paragraphs of a buffer.&quot;
  (interactive)
  (let ((point (point)))
    (unfill-region (point-min) (point-max))
    (goto-char point)))
&lt;/pre&gt;</description>
 <comments>http://nolan.eakins.net/node/208#comment</comments>
 <category domain="http://nolan.eakins.net/taxonomy/term/27">Emacs</category>
 <pubDate>Sun, 21 Aug 2005 02:41:28 -0700</pubDate>
 <dc:creator>sneakin</dc:creator>
 <guid isPermaLink="false">208 at http://nolan.eakins.net</guid>
</item>
</channel>
</rss>
