Commit b14c0c55 authored by Alan Mackenzie's avatar Alan Mackenzie
Browse files

progmodes/cc-guess.el: New file.

progmodes/cc-langs.el (c-mode-menu): Added "Style..." submenu.
progmodes/cc-styles.el (cc-choose-style-for-mode): New function derived
from `c-basic-common-init'.
progmodes/cc-mode.el (top-level): Require cc-guess.
(c-basic-common-init): Use `cc-choose-style-for-mode'.
parent 1fa280a3
2011-06-30 Mastake YAMATO <yamato@redhat.com>
* progmodes/cc-guess.el: New file.
* progmodes/cc-langs.el (c-mode-menu): Added "Style..." submenu.
* progmodes/cc-styles.el (cc-choose-style-for-mode): New function
derived from `c-basic-common-init'.
* progmodes/cc-mode.el (top-level): Require cc-guess.
(c-basic-common-init): Use `cc-choose-style-for-mode'.
2011-06-30 Lawrence Mitchell <wence@gmx.li>
* progmodes/js.el (js-mode): Don't stomp on global settings (bug#8933).
......
This diff is collapsed.
......@@ -295,6 +295,19 @@ the evaluated constant value at compile time."
["Backslashify" c-backslash-region
(c-fn-region-is-active-p)]))
"----"
("Style..."
["Set Style..." c-set-style t]
["Show Current Style Name" (message
"Style Name: %s"
c-indentation-style) t]
["Guess Style from this Buffer" c-guess-buffer-no-install t]
["Install the Last Guessed Style..." c-guess-install
(and c-guess-guessed-offsets-alist
c-guess-guessed-basic-offset) ]
["View the Last Guessed Style" c-guess-view
(and c-guess-guessed-offsets-alist
c-guess-guessed-basic-offset) ])
"----"
("Toggle..."
["Syntactic indentation" c-toggle-syntactic-indentation
:style toggle :selected c-syntactic-indentation]
......
......@@ -93,6 +93,7 @@
(cc-require 'cc-cmds)
(cc-require 'cc-align)
(cc-require 'cc-menus)
(cc-require 'cc-guess)
;; Silence the compiler.
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
......@@ -553,11 +554,7 @@ that requires a literal mode spec at compile time."
(c-clear-found-types)
;; now set the mode style based on default-style
(let ((style (if (stringp default-style)
default-style
(or (cdr (assq mode default-style))
(cdr (assq 'other default-style))
"gnu"))))
(let ((style (cc-choose-style-for-mode mode default-style)))
;; Override style variables if `c-old-style-variable-behavior' is
;; set. Also override if we are using global style variables,
;; have already initialized a style once, and are switching to a
......@@ -692,7 +689,8 @@ This function is called from the hook `before-hack-local-variables-hook'."
(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)))
(and (= cfs-in-file-and-dir-count cfs-in-dir-count)
'keep-defaults)))
(c-set-style stile)))
(when offsets
(mapc
......
......@@ -650,6 +650,15 @@ any reason to call this function directly."
(setq c-style-variables-are-local-p t))
))
(defun cc-choose-style-for-mode (mode default-style)
"Return suitable style for MODE from DEFAULT-STYLE.
DEFAULT-STYLE has the same format as `c-default-style'."
(if (stringp default-style)
default-style
(or (cdr (assq mode default-style))
(cdr (assq 'other default-style))
"gnu")))
(cc-provide 'cc-styles)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment