svn rev #23078: trunk/src/util/
tlyu@MIT.EDU
tlyu at MIT.EDU
Wed Oct 28 13:18:04 EDT 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=23078
Commit By: tlyu
Log Message:
Update to use heuristics for setting "krb5" style based on file local
variable settings. Improve friendliness of variant loading orders.
Changed Files:
U trunk/src/util/krb5-batch-reindent.el
U trunk/src/util/krb5-c-style.el
Modified: trunk/src/util/krb5-batch-reindent.el
===================================================================
--- trunk/src/util/krb5-batch-reindent.el 2009-10-28 17:09:00 UTC (rev 23077)
+++ trunk/src/util/krb5-batch-reindent.el 2009-10-28 17:18:04 UTC (rev 23078)
@@ -20,11 +20,11 @@
(untabify (point-min) (point-max)))
;; Only reindent if the file C style is guessed to be "krb5".
- (if (and (eq c-basic-offset 4)
- (eq indent-tabs-mode nil))
- (progn
- (c-set-style "krb5")
- (c-indent-region (point-min) (point-max))))
+ ;; Note that krb5-c-style.el already has a heuristic for setting
+ ;; the C style if the file has "c-basic-offset: 4;
+ ;; indent-tabs-mode: nil".
+ (if (equal c-indentation-style "krb5")
+ (c-indent-region (point-min) (point-max)))
(whitespace-cleanup)
Modified: trunk/src/util/krb5-c-style.el
===================================================================
--- trunk/src/util/krb5-c-style.el 2009-10-28 17:09:00 UTC (rev 23077)
+++ trunk/src/util/krb5-c-style.el 2009-10-28 17:18:04 UTC (rev 23078)
@@ -24,7 +24,24 @@
(c-special-indent-hook . nil)
(fill-column . 79)))
-(defun krb5-c-hook ()
- (c-add-style "krb5" krb5-c-style))
+;; Use eval-after-load rather than c-initialization-hook; this ensures
+;; that the style gets defined even if a user loads this file after
+;; initializing cc-mode.
+(eval-after-load 'cc-mode (c-add-style "krb5" krb5-c-style))
-(add-hook 'c-initialization-hook 'krb5-c-hook)
+;; We don't use a c-file-style file-local variable setting in our
+;; source code, to avoid errors for emacs users who don't define the
+;; "krb5" style. Instead, use this heuristic.
+;;
+;; TODO: modify to also look for unique files in the source tree.
+(defun krb5-c-mode-hook ()
+ (if (and (eq major-mode 'c-mode)
+ (eq c-basic-offset 4)
+ (eq indent-tabs-mode nil))
+ (c-set-style "krb5")))
+
+;; (add-hook 'c-mode-common-hook 'krb5-c-mode-hook)
+
+;; Use hack-local-variables-hook because the c-mode hooks run before
+;; hack-local-variables runs.
+(add-hook 'hack-local-variables-hook 'krb5-c-mode-hook)
More information about the cvs-krb5
mailing list