[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r100846: Enhance `c-file-style' in fi
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r100846: Enhance `c-file-style' in file/directory local variables. |
Date: |
Sun, 18 Jul 2010 20:28:00 +0000 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 100846
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sun 2010-07-18 20:28:00 +0000
message:
Enhance `c-file-style' in file/directory local variables.
cc-mode.el (c-count-cfss): New function.
(c-before-hack-hook): Call `c-set-style' differently according to whether
c-file-style was set in file or directory local variables.
modified:
lisp/ChangeLog
lisp/progmodes/cc-mode.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2010-07-18 18:44:32 +0000
+++ b/lisp/ChangeLog 2010-07-18 20:28:00 +0000
@@ -1,3 +1,11 @@
+2010-07-18 Alan Mackenzie <address@hidden>
+
+ Enhance `c-file-style' in file/directory local variables.
+ * cc-mode.el (c-count-cfss): New function.
+ (c-before-hack-hook): Call `c-set-style' differently according to
+ whether c-file-style was set in file or directory local
+ variables.
+
2010-07-18 Michael R. Mauger <address@hidden>
* progmodes/sql.el: Version 2.2.
=== modified file 'lisp/progmodes/cc-mode.el'
--- a/lisp/progmodes/cc-mode.el 2010-07-10 18:52:53 +0000
+++ b/lisp/progmodes/cc-mode.el 2010-07-18 20:28:00 +0000
@@ -662,6 +662,17 @@
(and (cdr rfn)
(setq require-final-newline mode-require-final-newline)))))
+(defun c-count-cfss (lv-alist)
+ ;; LV-ALIST is an alist like `file-local-variables-alist'. Count how many
+ ;; elements with the key `c-file-style' there are in it.
+ (let ((elt-ptr lv-alist) elt (cownt 0))
+ (while elt-ptr
+ (setq elt (car elt-ptr)
+ elt-ptr (cdr elt-ptr))
+ (when (eq (car elt) 'c-file-style)
+ (setq cownt (1+ cownt))))
+ cownt))
+
(defun c-before-hack-hook ()
"Set the CC Mode style and \"offsets\" when in the buffer's local variables.
They are set only when, respectively, the pseudo variables
@@ -678,7 +689,15 @@
(delq mode-cons file-local-variables-alist)))
(when stile
(or (stringp stile) (error "c-file-style is not a string"))
- (c-set-style stile))
+ (if (boundp 'dir-local-variables-alist)
+ ;; Determine whether `c-file-style' was set in the file's local
+ ;; variables or in a .dir-locals.el (a directory setting).
+ (let ((cfs-in-file-and-dir-count
+ (c-count-cfss file-local-variables-alist))
+ (cfs-in-dir-count (c-count-cfss dir-local-variables-alist)))
+ (c-set-style stile
+ (= cfs-in-file-and-dir-count cfs-in-dir-count)))
+ (c-set-style stile)))
(when offsets
(mapc
(lambda (langentry)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r100846: Enhance `c-file-style' in file/directory local variables.,
Alan Mackenzie <=