diff options
| author | Martin Stjernholm | 2003-01-28 00:41:35 +0000 |
|---|---|---|
| committer | Martin Stjernholm | 2003-01-28 00:41:35 +0000 |
| commit | e2c21e666f60debbc4c175bbca7c0c71c3a76bb8 (patch) | |
| tree | b9e701e83a7c786c9842ce1658c38c240c129404 /lisp | |
| parent | c922a224f818a8311b078e632e2b8ea686fa0520 (diff) | |
| download | emacs-e2c21e666f60debbc4c175bbca7c0c71c3a76bb8.tar.gz emacs-e2c21e666f60debbc4c175bbca7c0c71c3a76bb8.zip | |
(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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 10 | ||||
| -rw-r--r-- | lisp/progmodes/cc-vars.el | 37 |
3 files changed, 47 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d2e5ca3fcb2..76befbb5904 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2003-01-28 Martin Stjernholm <bug-cc-mode@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/cc-vars.el, progmodes/cc-mode.el | ||
| 4 | (c-require-final-newline): Made this variable an alist to | ||
| 5 | specify a value for each language. The default value causes | ||
| 6 | `require-final-newline' to be set to t only in languages where | ||
| 7 | the standard requires a final newline. | ||
| 8 | |||
| 1 | 2003-01-27 Kim F. Storm <storm@cua.dk> | 9 | 2003-01-27 Kim F. Storm <storm@cua.dk> |
| 2 | 10 | ||
| 3 | * simple.el (kill-new): Improve doc string for yank-handler. | 11 | * simple.el (kill-new): Improve doc string for yank-handler. |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 5148ff72dea..2073a4a3371 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -299,7 +299,6 @@ | |||
| 299 | 299 | ||
| 300 | ;; these variables should always be buffer local; they do not affect | 300 | ;; these variables should always be buffer local; they do not affect |
| 301 | ;; indentation style. | 301 | ;; indentation style. |
| 302 | (make-local-variable 'require-final-newline) | ||
| 303 | (make-local-variable 'parse-sexp-ignore-comments) | 302 | (make-local-variable 'parse-sexp-ignore-comments) |
| 304 | (make-local-variable 'indent-line-function) | 303 | (make-local-variable 'indent-line-function) |
| 305 | (make-local-variable 'indent-region-function) | 304 | (make-local-variable 'indent-region-function) |
| @@ -326,8 +325,7 @@ | |||
| 326 | 'c-indent-new-comment-line))) | 325 | 'c-indent-new-comment-line))) |
| 327 | 326 | ||
| 328 | ;; now set their values | 327 | ;; now set their values |
| 329 | (setq require-final-newline c-require-final-newline | 328 | (setq parse-sexp-ignore-comments t |
| 330 | parse-sexp-ignore-comments t | ||
| 331 | indent-line-function 'c-indent-line | 329 | indent-line-function 'c-indent-line |
| 332 | indent-region-function 'c-indent-region | 330 | indent-region-function 'c-indent-region |
| 333 | outline-regexp "[^#\n\^M]" | 331 | outline-regexp "[^#\n\^M]" |
| @@ -337,6 +335,12 @@ | |||
| 337 | comment-start-skip "/\\*+ *\\|//+ *" | 335 | comment-start-skip "/\\*+ *\\|//+ *" |
| 338 | comment-multi-line t) | 336 | comment-multi-line t) |
| 339 | 337 | ||
| 338 | ;; Set `require-final-newline' only if we should. | ||
| 339 | (let ((rfn (assq mode c-require-final-newline))) | ||
| 340 | (when rfn | ||
| 341 | (make-local-variable 'require-final-newline) | ||
| 342 | (setq require-final-newline (cdr rfn)))) | ||
| 343 | |||
| 340 | ;; Fix keyword regexps. | 344 | ;; Fix keyword regexps. |
| 341 | (c-init-language-vars) | 345 | (c-init-language-vars) |
| 342 | 346 | ||
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index f698065e24d..eb95508f2e3 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el | |||
| @@ -704,11 +704,38 @@ space." | |||
| 704 | :type 'function | 704 | :type 'function |
| 705 | :group 'c) | 705 | :group 'c) |
| 706 | 706 | ||
| 707 | (defcustom c-require-final-newline t | 707 | (defcustom c-require-final-newline |
| 708 | "*Controls whether a final newline is added to the file when saved. | 708 | ;; C and C++ mandates that all nonempty files should end with a |
| 709 | This value is given to `require-final-newline' at mode initialization; | 709 | ;; newline. Objective-C refers to C for all things it doesn't |
| 710 | see that variable for details." | 710 | ;; specify, so the same holds there. The other languages does not |
| 711 | :type 'symbol | 711 | ;; require it (at least not explicitly in a normative text). |
| 712 | '((c-mode . t) | ||
| 713 | (c++-mode . t) | ||
| 714 | (objc-mode . t)) | ||
| 715 | "*Controls whether a final newline is ensured when the file is saved. | ||
| 716 | The value is an association list that for each language mode specifies | ||
| 717 | the value to give to `require-final-newline' at mode initialization; | ||
| 718 | see that variable for details about the value. If a language isn't | ||
| 719 | present on the association list, CC Mode won't set | ||
| 720 | `require-final-newline' in buffers for that language." | ||
| 721 | :type `(set (cons :format "%v" | ||
| 722 | (const :format "C " c-mode) | ||
| 723 | (symbol :format "%v" :value ,require-final-newline)) | ||
| 724 | (cons :format "%v" | ||
| 725 | (const :format "C++ " c++-mode) | ||
| 726 | (symbol :format "%v" :value ,require-final-newline)) | ||
| 727 | (cons :format "%v" | ||
| 728 | (const :format "ObjC " objc-mode) | ||
| 729 | (symbol :format "%v" :value ,require-final-newline)) | ||
| 730 | (cons :format "%v" | ||
| 731 | (const :format "Java " java-mode) | ||
| 732 | (symbol :format "%v" :value ,require-final-newline)) | ||
| 733 | (cons :format "%v" | ||
| 734 | (const :format "IDL " idl-mode) | ||
| 735 | (symbol :format "%v" :value ,require-final-newline)) | ||
| 736 | (cons :format "%v" | ||
| 737 | (const :format "Pike " pike-mode) | ||
| 738 | (symbol :format "%v" :value ,require-final-newline))) | ||
| 712 | :group 'c) | 739 | :group 'c) |
| 713 | 740 | ||
| 714 | (defcustom c-electric-pound-behavior nil | 741 | (defcustom c-electric-pound-behavior nil |