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
|