]> git.eshelyaron.com Git - emacs.git/commitdiff
(c-require-final-newline): Made this variable an alist to specify a value
authorMartin Stjernholm <mast@lysator.liu.se>
Tue, 28 Jan 2003 00:41:35 +0000 (00:41 +0000)
committerMartin Stjernholm <mast@lysator.liu.se>
Tue, 28 Jan 2003 00:41:35 +0000 (00:41 +0000)
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.

lisp/ChangeLog
lisp/progmodes/cc-mode.el
lisp/progmodes/cc-vars.el

index d2e5ca3fcb2700afd649f45be3d56991db71f03a..76befbb59044e2824ce60c5e82d742b0b1395313 100644 (file)
@@ -1,3 +1,11 @@
+2003-01-28  Martin Stjernholm  <bug-cc-mode@gnu.org>
+
+       * progmodes/cc-vars.el, progmodes/cc-mode.el
+       (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.
+
 2003-01-27  Kim F. Storm  <storm@cua.dk>
 
        * simple.el (kill-new): Improve doc string for yank-handler.
index 5148ff72dea08af1fbe1463e470f524ca078f425..2073a4a3371a210bf0edb91b14d251f21c321d31 100644 (file)
 
   ;; 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)
               '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]"
        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)
 
index f698065e24db8ad3f2440229cb28282ceb6d8911..eb95508f2e304ca400e4289736d31d392a67bca9 100644 (file)
@@ -704,11 +704,38 @@ space."
   :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