emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch to remove minor modes in tutorial


From: Lennart Borgman
Subject: Patch to remove minor modes in tutorial
Date: Sat, 24 Jun 2006 16:09:11 +0200
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

Some while ago I complained that the tutorial did not work if some minor modes where enabled. Attached is a patch for that. (I am not sure if I have sent this before. I asked for help installing them, but I did not get that.)


Index: lisp/help-fns.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/help-fns.el,v
retrieving revision 1.89
diff -u -r1.89 help-fns.el
--- lisp/help-fns.el    11 May 2006 11:10:45 -0000      1.89
+++ lisp/help-fns.el    16 Jun 2006 22:07:02 -0000
@@ -98,7 +98,86 @@
          (newline (- n (/ n 2)))))
       (goto-char (point-min))
       (setq buffer-undo-list nil)
-      (set-buffer-modified-p nil))))
+      (set-buffer-modified-p nil)))
+
+  ;; Check if minor modes may disturb
+  (let (minor-modes-on minor-modes unknown)
+    (dolist (m minor-mode-list)
+      (let ((fmode (or (get m :minor-mode-function) m)))
+      (when (and (boundp m) (symbol-value m)
+                 (fboundp fmode)
+                 (condition-case err
+                     (progn
+                       (unless
+                           (equal '(keymap)
+                                  (symbol-value
+                                   (read (concat (symbol-name m) "-map"))))
+                         t))
+                   (error nil)))
+        (add-to-list 'minor-modes m))))
+    (dolist (m minor-mode-alist)
+      (add-to-list 'minor-modes (car m)))
+    (dolist (m minor-modes)
+      (when (symbol-value m)
+        (add-to-list 'minor-modes-on m)))
+
+    ;; Default minor modes
+    (dolist (m '(auto-compression-mode
+                 blink-cursor-mode
+                 encoded-kbd-mode
+                 file-name-shadow-mode
+                 font-lock-mode
+                 global-font-lock-mode
+                 line-number-mode
+                 menu-bar-mode
+                 mouse-wheel-mode
+                 tool-bar-mode
+                 tooltip-mode
+                 unify-8859-on-encoding-mode
+                 utf-translate-cjk-mode))
+      (setq minor-modes-on (delete m minor-modes-on)))
+
+    ;; Special
+    (when cua-mode
+      (add-to-list 'minor-modes-on 'cua-mode))
+
+    (when minor-modes-on
+      (setq minor-modes-on (sort minor-modes-on 'string<))
+      (let (remove-minor
+            (modes-on (copy-seq minor-modes-on))
+            )
+        (with-temp-buffer
+          (insert "\nYou are using some minor modes (")
+          (dolist (m modes-on)
+            (insert (format "%s" (car modes-on)))
+            (setq modes-on (cdr modes-on))
+            (if (= 1 (length modes-on))
+                (insert " and ")
+              (when modes-on (insert ", "))))
+          (insert
+           ") which can possibly override global key bindings."
+           "  The behavior of Emacs with these modes may"
+           " not match what the tutorial teaches.\n\n"
+           "Do you want to disable these modes when you are in the tutorial?"
+           "(y-or-n)"
+           )
+          (fill-region (point-min) (point-max))
+          (let ((use-dialog-box nil))
+            (setq remove-minor
+                  (y-or-n-p (format "%s " (buffer-substring
+                                           (point-min)
+                                           (- (point-max) 8)))))))
+        (if remove-minor
+            (progn
+              (make-local-variable 'emulation-mode-map-alists)
+              (setq emulation-mode-map-alists nil)
+              (dolist (m minor-modes-on)
+                (make-local-variable m)
+                (set m nil))
+              (message "Removed those bindings for the tutorial only."))
+          (message
+           "Please note that the tutorial may not work with this choice.")
+          )))))
 
 
 ;; Functions
@@ -325,6 +404,8 @@
                 "a Lisp macro")
                ((eq (car-safe def) 'autoload)
                 (setq file-name (nth 1 def))
+                (let ((loc (locate-library file-name)))
+                   (when loc (setq file-name loc)))
                 (format "%s autoloaded %s"
                         (if (commandp def) "an interactive" "an")
                         (if (eq (nth 4 def) 'keymap) "keymap"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]