+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.
;; 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)
: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