]> git.eshelyaron.com Git - emacs.git/commitdiff
(mode-line-copied-mode-name): New variable.
authorRichard M. Stallman <rms@gnu.org>
Tue, 22 Jan 2002 22:47:14 +0000 (22:47 +0000)
committerRichard M. Stallman <rms@gnu.org>
Tue, 22 Jan 2002 22:47:14 +0000 (22:47 +0000)
(mode-line-mode-name): Don't modify mode-name itself!
Instead, make a copy and reuse it.

lisp/ChangeLog
lisp/bindings.el

index 49b23c623a639f582d2142793683c046af15f09a..e809b7874501f0c7e5a03419fb4ef910fecd1fc6 100644 (file)
@@ -1,5 +1,11 @@
 2002-01-22  Richard M. Stallman  <rms@gnu.org>
 
+       * bindings.el (mode-line-copied-mode-name): New variable.
+       (mode-line-mode-name): Don't modify mode-name itself!
+       Instead, make a copy and reuse it.
+
+       * subr.el (copy-without-properties): New function.
+
        * progmodes/sh-script.el (sh-set-shell): Doc fix.
 
        * net/ange-ftp.el (ange-ftp-canonize-filename): Avoid duplicate
index f034e57c8cfa4d7487f5c2460aa84fc7521eeeff..56ee9c2021acde6152b8ec30c4e7a47ea7bdfa36 100644 (file)
@@ -316,28 +316,19 @@ Menu of mode operations in the mode line.")
       (if binding
          (call-interactively binding)))))
 
+(defvar mode-line-copied-mode-name nil
+  "A copy of `mode-name', with `help-echo' and `local-map' properties added.")
+
 (defun mode-line-mode-name () "\
 Return a string to display in the mode line for the current mode name."
   (when (stringp mode-name)
-    (let ((local-map (get-text-property 0 'local-map mode-name))
-         (help-echo (get-text-property 0 'help-echo mode-name)))
-      ;; For correctness, we shouldn't modify mode-name.  But adding some
-      ;; text-properties to those mode-name strings can't hurt, really, and
-      ;; furthermore, by doing it in-place, we make sure that we don't need to
-      ;; do the work over and over and over and ....  -stef
-      (unless (and local-map help-echo)
-       (setq mode-name (copy-sequence mode-name)))
-      ;; Add `local-map' property if there isn't already one.
-      (unless (or local-map
-                 (next-single-property-change 0 'local-map mode-name))
-       (put-text-property 0 (length mode-name)
-                          'local-map mode-line-minor-mode-keymap mode-name)
-       ;; Add `help-echo' property if there isn't already one.
-       (unless (or help-echo
-                   (next-single-property-change 0 'help-echo mode-name))
-         (put-text-property 0 (length mode-name) 'help-echo
-                            "mouse-3: minor mode menu" mode-name)))))
-  mode-name)
+    (if (equal mode-name mode-line-copied-mode-name)
+       mode-line-copied-mode-name
+      (setq mode-line-copied-mode-name
+           (propertize mode-name
+                       'local-map mode-line-minor-mode-keymap 
+                       'help-echo "mouse-3: minor mode menu"))))
+  mode-line-copied-mode-name)
 
 (defmacro bound-and-true-p (var)
   "Return the value of symbol VAR if it is bound, else nil."