Avoid crash on composition (backport from trunk).
[emacs.git] / lisp / cedet / srecode / filters.el
blob0afd32bbb4192d035e32306a19f2d73682896dfc
1 ;;; srecode/filters.el --- Filters for use in template variables.
3 ;; Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
22 ;;; Commentary:
24 ;; Various useful srecoder template functions.
26 ;;; Code:
28 (require 'newcomment)
29 (require 'srecode/table)
30 (require 'srecode/insert)
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 "")
43 (while strs
44 (cond ((and (not comment-multi-line) (string= (car strs) ""))
45 ; (setq newstr (concat newstr "\n")))
48 (setq newstr (concat newstr cs " " (car strs)))))
49 (setq strs (cdr strs))
50 (when strs (setq newstr (concat newstr "\n"))))
51 newstr))
53 (provide 'srecode/filters)
55 ;;; srecode/filters.el ends here
57 ;; arch-tag: fcc95ddc-8d9a-4b15-bb51-2707ead986c7