aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii2005-05-07 15:06:42 +0000
committerEli Zaretskii2005-05-07 15:06:42 +0000
commite6469973d4a91ec2a80b0a6abd176892874e1f9b (patch)
treee2f3c860b3583de95e5a360e234e41a2f4ee4bdc /lisp
parent06df7f877bf6db98b8540636819d14114160aee6 (diff)
downloademacs-e6469973d4a91ec2a80b0a6abd176892874e1f9b.tar.gz
emacs-e6469973d4a91ec2a80b0a6abd176892874e1f9b.zip
(easy-mmode-pretty-mode-name): Explain
more about the LIGHTER arg's usage in the doc string. Add commentary to clarify what the code does. Fix the regexp that strips whitespace from LIGHTER. Quote LIGHTER before using it, since it could have characters special to regular expressions.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/easy-mmode.el19
2 files changed, 24 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 48253061bfa..da4e1c89976 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12005-05-07 Eli Zaretskii <eliz@gnu.org>
2
3 * emacs-lisp/easy-mmode.el (easy-mmode-pretty-mode-name): Explain
4 more about the LIGHTER arg's usage in the doc string. Add
5 commentary to clarify what the code does. Fix the regexp that
6 strips whitespace from LIGHTER. Quote LIGHTER before using it,
7 since it could have characters special to regular expressions.
8
12005-05-07 Matt Hodges <MPHodges@member.fsf.org> (tiny change) 92005-05-07 Matt Hodges <MPHodges@member.fsf.org> (tiny change)
2 10
3 * replace.el (occur-1): Bind inhibit-read-only so that 11 * replace.el (occur-1): Bind inhibit-read-only so that
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 831ffb2d576..94db7cc586f 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -58,16 +58,29 @@
58 58
59(defun easy-mmode-pretty-mode-name (mode &optional lighter) 59(defun easy-mmode-pretty-mode-name (mode &optional lighter)
60 "Turn the symbol MODE into a string intended for the user. 60 "Turn the symbol MODE into a string intended for the user.
61If provided LIGHTER will be used to help choose capitalization." 61If provided, LIGHTER will be used to help choose capitalization by,
62replacing its case-insensitive matches with the literal string in LIGHTER."
62 (let* ((case-fold-search t) 63 (let* ((case-fold-search t)
64 ;; Produce "Foo-Bar Minor mode" from foo-bar-minor-mode.
63 (name (concat (replace-regexp-in-string 65 (name (concat (replace-regexp-in-string
66 ;; "Foo-Bar-Minor" -> "Foo-Bar minor"
64 "-Minor" " minor" 67 "-Minor" " minor"
68 ;; "foo-bar-minor" -> "Foo-Bar-Minor"
65 (capitalize (replace-regexp-in-string 69 (capitalize (replace-regexp-in-string
70 ;; "foo-bar-minor-mode" -> "foo-bar-minor"
66 "-mode\\'" "" (symbol-name mode)))) 71 "-mode\\'" "" (symbol-name mode))))
67 " mode"))) 72 " mode")))
68 (if (not (stringp lighter)) name 73 (if (not (stringp lighter)) name
69 (setq lighter (replace-regexp-in-string "\\`\\s-+\\|\\-s+\\'" "" lighter)) 74 ;; Strip leading and trailing whitespace from LIGHTER.
70 (replace-regexp-in-string lighter lighter name t t)))) 75 (setq lighter (replace-regexp-in-string "\\`\\s-+\\|\\s-+\\'" ""
76 lighter))
77 ;; Replace any (case-insensitive) matches for LIGHTER in NAME
78 ;; with a literal LIGHTER. E.g., if NAME is "Iimage mode" and
79 ;; LIGHTER is " iImag", then this will produce "iImage mode".
80 ;; (LIGHTER normally comes from the mode-line string passed to
81 ;; define-minor-mode, and normally includes at least one leading
82 ;; space.)
83 (replace-regexp-in-string (regexp-quote lighter) lighter name t t))))
71 84
72;;;###autoload 85;;;###autoload
73(defalias 'easy-mmode-define-minor-mode 'define-minor-mode) 86(defalias 'easy-mmode-define-minor-mode 'define-minor-mode)