Mercurial > emacs
changeset 49496:2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
for each language. The default value causes `require-final-newline' to be
set to t only in languages where the standard requires a final newline.
author | Martin Stjernholm <mast@lysator.liu.se> |
---|---|
date | Tue, 28 Jan 2003 00:41:21 +0000 |
parents | c6abb7476297 |
children | 54411340abe6 |
files | lisp/progmodes/cc-mode.el lisp/progmodes/cc-vars.el |
diffstat | 2 files changed, 39 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/cc-mode.el Mon Jan 27 22:19:26 2003 +0000 +++ b/lisp/progmodes/cc-mode.el Tue Jan 28 00:41:21 2003 +0000 @@ -299,7 +299,6 @@ ;; these variables should always be buffer local; they do not affect ;; indentation style. - (make-local-variable 'require-final-newline) (make-local-variable 'parse-sexp-ignore-comments) (make-local-variable 'indent-line-function) (make-local-variable 'indent-region-function) @@ -326,8 +325,7 @@ 'c-indent-new-comment-line))) ;; now set their values - (setq require-final-newline c-require-final-newline - parse-sexp-ignore-comments t + (setq parse-sexp-ignore-comments t indent-line-function 'c-indent-line indent-region-function 'c-indent-region outline-regexp "[^#\n\^M]" @@ -337,6 +335,12 @@ comment-start-skip "/\\*+ *\\|//+ *" comment-multi-line t) + ;; Set `require-final-newline' only if we should. + (let ((rfn (assq mode c-require-final-newline))) + (when rfn + (make-local-variable 'require-final-newline) + (setq require-final-newline (cdr rfn)))) + ;; Fix keyword regexps. (c-init-language-vars)
--- a/lisp/progmodes/cc-vars.el Mon Jan 27 22:19:26 2003 +0000 +++ b/lisp/progmodes/cc-vars.el Tue Jan 28 00:41:21 2003 +0000 @@ -704,11 +704,38 @@ :type 'function :group 'c) -(defcustom c-require-final-newline t - "*Controls whether a final newline is added to the file when saved. -This value is given to `require-final-newline' at mode initialization; -see that variable for details." - :type 'symbol +(defcustom c-require-final-newline + ;; C and C++ mandates that all nonempty files should end with a + ;; newline. Objective-C refers to C for all things it doesn't + ;; specify, so the same holds there. The other languages does not + ;; require it (at least not explicitly in a normative text). + '((c-mode . t) + (c++-mode . t) + (objc-mode . t)) + "*Controls whether a final newline is ensured when the file is saved. +The value is an association list that for each language mode specifies +the value to give to `require-final-newline' at mode initialization; +see that variable for details about the value. If a language isn't +present on the association list, CC Mode won't set +`require-final-newline' in buffers for that language." + :type `(set (cons :format "%v" + (const :format "C " c-mode) + (symbol :format "%v" :value ,require-final-newline)) + (cons :format "%v" + (const :format "C++ " c++-mode) + (symbol :format "%v" :value ,require-final-newline)) + (cons :format "%v" + (const :format "ObjC " objc-mode) + (symbol :format "%v" :value ,require-final-newline)) + (cons :format "%v" + (const :format "Java " java-mode) + (symbol :format "%v" :value ,require-final-newline)) + (cons :format "%v" + (const :format "IDL " idl-mode) + (symbol :format "%v" :value ,require-final-newline)) + (cons :format "%v" + (const :format "Pike " pike-mode) + (symbol :format "%v" :value ,require-final-newline))) :group 'c) (defcustom c-electric-pound-behavior nil