Emacs : Information and code concerning Emacs
Updated: 3/3/2003; 8:35:40 AM.

 

Subscribe to "Emacs" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Wednesday, February 05, 2003

Something that I should read!
6:15:11 PM    

Today I whipped up a quick Elisp function that adds folding marks (to be used with Folding Mode).  This function is not perfect, but it can get folding marks in your code quickly so that you can step through and customize them to be more meaningful.  Just thought I would share with the world.  I haven't posted this to comp.emacs.sources yet. 

If you find this useful or enhance it, please let me know.

(defun user-add-sql-folding-marks()
"This steps through a SQL buffer and adds folding marks around all
statement blocks that have a "begin" and an "end".  Can be useful
for large procedures."
  (interactive)
  (save-excursion
 (goto-char (point-min))
 (while (not (eobp))
   (forward-line 1)
   (if (looking-at "^\\W*begin")
    (progn
   (forward-line -1)
   (goto-char (point-at-bol))
   (let ((cur-statement (buffer-substring (point-at-bol) (point-at-eol))))
     (insert "\n")
     (forward-line -1)
     (insert (concat "/* {{{ " (concat cur-statement " */")))
     (forward-line 2)))
  (if (and (looking-at "^\\W*end")
     (not (looking-at "^\\W*end)")))
   (progn
     (forward-line 1)
     (insert "/* }}} */\n")
     (forward-line -1)))))))


6:13:05 PM    

© Copyright 2003 Tom Pierce.



Click here to visit the Radio UserLand website.

 


February 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28  
Jan   Mar