]> code.delx.au - gnu-emacs/blob - lisp/cedet/srecode/filters.el
Add 2012 to FSF copyright years for Emacs files (do not merge to trunk)
[gnu-emacs] / lisp / cedet / srecode / filters.el
1 ;;; srecode/filters.el --- Filters for use in template variables.
2
3 ;; Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23 ;;
24 ;; Various useful srecoder template functions.
25
26 ;;; Code:
27
28 (require 'newcomment)
29 (require 'srecode/table)
30 (require 'srecode/insert)
31
32 (defun srecode-comment-prefix (str)
33 "Prefix each line of STR with the comment prefix characters."
34 (let* ((dict srecode-inserter-variable-current-dictionary)
35 ;; Derive the comment characters to put in front of each line.
36 (cs (or (and dict
37 (srecode-dictionary-lookup-name dict "comment_prefix"))
38 (and comment-multi-line comment-continue)
39 (and (not comment-multi-line) comment-start)))
40 (strs (split-string str "\n"))
41 (newstr "")
42 )
43 (while strs
44 (cond ((and (not comment-multi-line) (string= (car strs) ""))
45 ; (setq newstr (concat newstr "\n")))
46 )
47 (t
48 (setq newstr (concat newstr cs " " (car strs)))))
49 (setq strs (cdr strs))
50 (when strs (setq newstr (concat newstr "\n"))))
51 newstr))
52
53 (provide 'srecode/filters)
54
55 ;;; srecode/filters.el ends here
56
57 ;; arch-tag: fcc95ddc-8d9a-4b15-bb51-2707ead986c7