From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: major mode in new buffers Date: Thu, 01 Apr 2010 21:05:30 +0300 Organization: JURTA Message-ID: <87fx3f5d15.fsf@mail.jurta.org> References: <2f8988ff1003300457w38ee4bf0h259cd7a7187298e0@mail.gmail.com> <87oci5ev6a.fsf@mail.jurta.org> <87oci41zrg.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1270145559 7907 80.91.229.12 (1 Apr 2010 18:12:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 1 Apr 2010 18:12:39 +0000 (UTC) Cc: Kyllingstad , Stefan Monnier , =?iso-8859-1?Q?Ren=E9?=, emacs-devel@gnu.org To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 01 20:12:30 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NxOsY-0000K4-BC for ged-emacs-devel@m.gmane.org; Thu, 01 Apr 2010 20:12:30 +0200 Original-Received: from localhost ([127.0.0.1]:58356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxOsX-0008Cj-Lc for ged-emacs-devel@m.gmane.org; Thu, 01 Apr 2010 14:12:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NxOnR-0006N0-0y for emacs-devel@gnu.org; Thu, 01 Apr 2010 14:07:13 -0400 Original-Received: from [140.186.70.92] (port=42701 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxOnP-0006MU-B8 for emacs-devel@gnu.org; Thu, 01 Apr 2010 14:07:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NxOnM-00066S-4W for emacs-devel@gnu.org; Thu, 01 Apr 2010 14:07:11 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:44347 helo=mx1.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NxOnL-00065o-Py for emacs-devel@gnu.org; Thu, 01 Apr 2010 14:07:08 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.34.136.cable.starman.ee [82.131.34.136]) by mx1.starman.ee (Postfix) with ESMTP id 889923F40C3; Thu, 1 Apr 2010 21:07:00 +0300 (EEST) In-Reply-To: (Juanma Barranquero's message of "Wed, 31 Mar 2010 18:35:20 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:123028 Archived-At: >> 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/