[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: major mode in new buffers
From: |
Juri Linkov |
Subject: |
Re: major mode in new buffers |
Date: |
Thu, 01 Apr 2010 21:05:30 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) |
>> Ehelp creates a problem and tries to solve it in an ugly way.
>
> I know, and I would be very happy if someone were to rewrite it from
> the ground up. Still, it's a fact that it currently "works", and your
> major-mode code (which I find very useful) breaks it. I thought you'd
> be interested in knowing that.
I know nothing about ehelp.el, but it seems this patch fixes it:
=== modified file 'lisp/ehelp.el'
--- lisp/ehelp.el 2010-01-13 08:35:10 +0000
+++ lisp/ehelp.el 2010-04-01 18:05:05 +0000
@@ -94,10 +94,13 @@ (defvar electric-help-map
map)
"Keymap defining commands available in `electric-help-mode'.")
+(defvar electric-help-orig-major-mode nil)
+
(defun electric-help-mode ()
"`with-electric-help' temporarily places its buffer in this mode.
-\(On exit from `with-electric-help', the buffer is put in default
`major-mode'.)"
+\(On exit from `with-electric-help', the original `major-mode' is restored.)"
(setq buffer-read-only t)
+ (set (make-local-variable 'electric-help-orig-major-mode) major-mode)
(setq mode-name "Help")
(setq major-mode 'help)
(setq mode-line-buffer-identification '(" Help: %b"))
@@ -131,7 +134,7 @@ (defun with-electric-help (thunk &option
When the user exits (with `electric-help-exit', or otherwise), the help
buffer's window disappears (i.e., we use `save-window-excursion'), and
-BUFFER is put into default `major-mode' (or `fundamental-mode')."
+BUFFER is put back into its original major mode."
(setq buffer (get-buffer-create (or buffer "*Help*")))
(let ((one (one-window-p t))
(config (current-window-configuration))
@@ -175,8 +178,9 @@ (defun with-electric-help (thunk &option
;; call to help-mode won't cut it; at least RET is bound wrong
;; afterwards. It's also not clear that `help-mode' is always
;; the right thing, maybe we should add an optional parameter.
+ ;; Now we restore the original major mode saved by `electric-help-mode'.
(condition-case ()
- (funcall (or (default-value 'major-mode) 'fundamental-mode))
+ (funcall (or electric-help-orig-major-mode 'fundamental-mode))
(error nil))
(set-window-configuration config)
--
Juri Linkov
http://www.jurta.org/emacs/
- Re: major mode in new buffers,
Juri Linkov <=
- Re: major mode in new buffers, Juanma Barranquero, 2010/04/01
- Re: major mode in new buffers, Juanma Barranquero, 2010/04/01
- Re: major mode in new buffers, Juri Linkov, 2010/04/01
- Re: major mode in new buffers, Juanma Barranquero, 2010/04/01
- Re: major mode in new buffers, Juri Linkov, 2010/04/02
- Re: major mode in new buffers, Juanma Barranquero, 2010/04/02
- Re: major mode in new buffers, Juri Linkov, 2010/04/02