🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98345

Backspace and help bugs in Gnumacs 18.57

#98345
From: Andrew Arensburger - RMS
Date: Tue, 20 Aug 1991 22:50
250 lines
11325 bytes
	The included diff file corrects a pair of bugs in Gnumacs version
18.57 . The first, and easiest to fix is the fact that the 'backspace'
key (ASCII 8) is bound to the help menu. I changed this to M-h .
	The second bug, introduced by the first, is that one could not have
a multi-character help sequence (e.g., ESC-h). This is evidenced by the
fact that when I changed 'help_char' to a saner value, Gnumacs stopped
giving me the
		(Type ? for further options) "
prompt. I've fixed this in the following way: 'help_char' is no longer a
prefix, but rather calls the _function_ 'help-command'.
	'help-command', in turn, is simply a function that displays the
help prompt, reads a key from the keyboard, finds that key in the help
keymap, and executes the associated function.
	On a related note, 'help-for-help', which does pretty much the
same thing at one point, did not realize that it was possible to have multi-
key sequences (e.g., "M-h M-h" for 'help-for-help'). I've fixed this with
a call to the new routine 'find-in-keymap'.

					Andrew Arensburger
					arensb@kong.gsfc.nasa.gov

----- snip snip snip --------------------------------------------------
# These are the changes I've introduced locally. The main modifications
# are:
#	- The default help sequence is now M-h, instead of @$#@#$!! C-h
#	- The help stuff now admits that one might have a multi-character
#	  command (e.g., M-h).
# I've also stripped out most of the useless crud in loaddefs.el, but that's
# not reflected in this file.
#
#				Andrew Arensburger
#				Goddard Space Flight Center
#				Aug. 20, 1991
#
diff -cr emacs-18.57/lisp/help.el orig/emacs-18.57/lisp/help.el
*** emacs-18.57/lisp/help.el	Tue Aug 20 15:35:16 1991
--- orig/emacs-18.57/lisp/help.el	Wed Jan  9 17:00:25 1991
***************
*** 18,95 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
- (message "loading help")
  (defvar help-map (make-sparse-keymap)
    "Keymap for characters following the Help key.")
  
! (define-key global-map "\M-h" 'help-command)
  
! ;;; FIND-IN-KEYMAP
! ; 'keymap' is a sparse keymap. If 'c' is a valid key in 'keymap', then
! ; find the corresponding entry. If the entry is a sub-keymap (i.e.,
! ; the symbol is a prefix), then read a key from the keyboard and traverse
! ; the keymap recursively.
! ;     There are provisions for two kinds of keymaps: plain ones (e.g.,
! ; global-map), and sparse ones.
! ;
! (defun find-in-keymap (c keymap)
!   "Find the character C in the keymap KEYMAP."
!   ; Check the arguments
!   (cond ((not (keymapp keymap))       ; 'keymap' must be a keymap
! 	 (message "Not a keymap: %s" keymap))
! 	((not (integerp c))           ; 'c' must be an integer
! 	 (message "Not a valid ASCII code: %s" c))
! 	; 'c' is an integer, and 'keymap' is a keymap. Good.
! 	(t (cond ((arrayp keymap)                ; It's a plain keymap
! 		  (cond ((or (< c 0)             ; Out of bounds
! 			     (>= c (length keymap)))
! 			 (message "Illegal character"))
! 			; It's a valid character in a plain keymap. Look
! 			; it up. If the definition is another keymap,
! 			; call 'find-in-keymap' recursively. 
! 			(t (let ((defn (aref keymap c)))
! 			     (cond ((keymapp defn)
! 				    (find-in-keymap (read-char) defn))
! 				   (t defn))))))
! 		 ; It's (presumably) a sparse keymap. The 'assq' call
! 		 ; is supposed to return a structure of the form
! 		 ; (c . defn), where c is 'c', and defn is either another
! 		 ; keymap, or a symbol which (presumably, again) is the
! 		 ; name of a function to call.
! 		 ; If it's a keymap, read a character and call
! 		 ; find-in-keymap recursively.
! 		 (t (let ((defn (assq c (cdr keymap))))
! 		      (cond ((null defn) nil)    ; Paranoia
! 			    ((atom defn) defn)   ; Belt & suspenders
! 			    ((keymapp (cdr defn))
! 			     (find-in-keymap (read-char) (cdr defn)))
! 			    (t (cdr defn)))))))))
! 
! ;;; HELP-COMMAND
! ; The basic help command. It serves two functions: the first is to act
! ; as a help menu, i.e. by providing the user with an array of keys that
! ; will make various help texts show up.
! ;     "But," I hear you say, "couldn't you just have a help keymap, with
! ; a help character prefix?" This is, in fact, how it used to be implemented.
! ; There was even a cute bit of trickery whereby if a newbie pressed
! ; backspace (the default help character, for some reason I'll never under-
! ; stand), the minibuffer even gave him a cute little prompt.
! ;     Then I changed the default help character to M-h, and the newbie
! ; prompt disappeared. It turns out that the C portion of GNUmacs assumes
! ; that the help key is a single character.
! ;
! (defun help-command (c)
!   "The default help command. This is just a switch that reads in a character
! and selects a help screen."
!   (interactive "c(press ? for further options) - ")
!   ;;; Look the key up in the help keymap
!   (let ((func (find-in-keymap c help-map)))
!     ;;; If the key exists, call the corresponding function
!     (cond (func (call-interactively func))
! 	  (t (message "Invalid character")
! 	     c))))
! 
! (define-key help-map "\M-h" 'help-for-help)
  (define-key help-map "?" 'help-for-help)
  
  (define-key help-map "\C-c" 'describe-copying)
--- 18,30 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
  (defvar help-map (make-sparse-keymap)
    "Keymap for characters following the Help key.")
  
! (define-key global-map "\C-h" 'help-command)
! (fset 'help-command help-map)
  
! (define-key help-map "\C-h" 'help-for-help)
  (define-key help-map "?" 'help-for-help)
  
  (define-key help-map "\C-c" 'describe-copying)
***************
*** 230,236 ****
      (print-help-return-message)))
  
  (defun help-for-help ()
!   "You have typed M-h, the help character.  Type a Help option:
  
  A  command-apropos.   Give a substring, and see a list of commands
                (functions interactively callable) that contain
--- 165,171 ----
      (print-help-return-message)))
  
  (defun help-for-help ()
!   "You have typed C-h, the help character.  Type a Help option:
  
  A  command-apropos.   Give a substring, and see a list of commands
                (functions interactively callable) that contain
***************
*** 258,264 ****
  C-w print information on absence of warranty for GNU Emacs."
    (interactive)
    (message
!  "A B C F I K L M N S T V W C-c C-d C-n C-w.  Type C-h for more help: ")
    (let ((char (read-char)))
      (if (or (= char ?\C-h) (= char ??))
  	(save-window-excursion
--- 193,199 ----
  C-w print information on absence of warranty for GNU Emacs."
    (interactive)
    (message
!  "A B C F I K L M N S T V W C-c C-d C-n C-w.  Type C-h again for more help: ")
    (let ((char (read-char)))
      (if (or (= char ?\C-h) (= char ??))
  	(save-window-excursion
***************
*** 276,282 ****
  			 "" " or Space to scroll"))
  	    (let ((cursor-in-echo-area t))
  	      (setq char (read-char))))))
!     (let ((defn (find-in-keymap (downcase char) help-map)))
        (if defn (call-interactively defn) (ding)))))
  
  
--- 211,217 ----
  			 "" " or Space to scroll"))
  	    (let ((cursor-in-echo-area t))
  	      (setq char (read-char))))))
!     (let ((defn (cdr (assq (downcase char) (cdr help-map)))))
        (if defn (call-interactively defn) (ding)))))
  
  
diff -cr emacs-18.57/src/cmds.c orig/emacs-18.57/src/cmds.c
*** emacs-18.57/src/cmds.c	Tue Aug 13 11:19:18 1991
--- orig/emacs-18.57/src/cmds.c	Fri Jan  4 19:15:03 1991
***************
*** 342,346 ****
    ndefkey (Vglobal_map, Ctl ('E'), "end-of-line");
    ndefkey (Vglobal_map, Ctl ('F'), "forward-char");
    ndefkey (Vglobal_map, 0177, "delete-backward-char");
-   ndefkey (Vglobal_map, Ctl ('H'), "delete-backward-char");
  }
--- 342,345 ----
diff -cr emacs-18.57/src/keyboard.c orig/emacs-18.57/src/keyboard.c
*** emacs-18.57/src/keyboard.c	Tue Aug 20 16:40:28 1991
--- orig/emacs-18.57/src/keyboard.c	Tue Jan  8 20:40:31 1991
***************
*** 290,295 ****
--- 290,300 ----
  
        ptr = push_key_description (c, ptr);
        *ptr++ = ' ';
+       if (echoptr == echobuf && c == help_char)
+ 	{
+ 	  strcpy (ptr, "(Type ? for further options) ");
+ 	  ptr += strlen (ptr);
+ 	}
  
        *ptr = 0;
        echoptr = ptr;
***************
*** 2211,2217 ****
      "Character to recognize as meaning Help.\n\
  When it is read, do (eval help-form), and display result if it's a string.\n\
  If help-form's value is nil, this char can be read normally.");
!   help_char = Ctl ('H');	/* But this is never really used */
  
    DEFVAR_LISP ("help-form", &Vhelp_form,
      "Form to execute when character help-char is read.\n\
--- 2216,2222 ----
      "Character to recognize as meaning Help.\n\
  When it is read, do (eval help-form), and display result if it's a string.\n\
  If help-form's value is nil, this char can be read normally.");
!   help_char = Ctl ('H');
  
    DEFVAR_LISP ("help-form", &Vhelp_form,
      "Form to execute when character help-char is read.\n\
diff -cr emacs-18.57/src/minibuf.c orig/emacs-18.57/src/minibuf.c
*** emacs-18.57/src/minibuf.c	Tue Aug 13 11:22:31 1991
--- orig/emacs-18.57/src/minibuf.c	Tue Jan  8 12:59:58 1991
***************
*** 1096,1103 ****
    ndefkey (Vminibuffer_local_completion_map, Ctl ('g'), "abort-recursive-edit");
    ndefkey (Vminibuffer_local_completion_map, Ctl ('m'), "exit-minibuffer");
    ndefkey (Vminibuffer_local_completion_map, Ctl ('j'), "exit-minibuffer");
!   ndefkey (Vminibuffer_local_completion_map, ' ', "minibuffer-complete");
!   ndefkey (Vminibuffer_local_completion_map, '\t', "minibuffer-complete-word");
    ndefkey (Vminibuffer_local_completion_map, '?', "minibuffer-completion-help");
  
    ndefkey (Vminibuffer_local_must_match_map, Ctl ('g'), "abort-recursive-edit");
--- 1096,1103 ----
    ndefkey (Vminibuffer_local_completion_map, Ctl ('g'), "abort-recursive-edit");
    ndefkey (Vminibuffer_local_completion_map, Ctl ('m'), "exit-minibuffer");
    ndefkey (Vminibuffer_local_completion_map, Ctl ('j'), "exit-minibuffer");
!   ndefkey (Vminibuffer_local_completion_map, '\t', "minibuffer-complete");
!   ndefkey (Vminibuffer_local_completion_map, ' ', "minibuffer-complete-word");
    ndefkey (Vminibuffer_local_completion_map, '?', "minibuffer-completion-help");
  
    ndefkey (Vminibuffer_local_must_match_map, Ctl ('g'), "abort-recursive-edit");
Technical Details
Message-ID: <9108202250.AA14480@kong.gsfc.nasa.gov>
Path: arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!rusmv1!ira.uka.de!yale.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!kong.gsfc.nasa.gov!arensb

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,552ba8344f367969,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-08-20 15:50:01 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!rusmv1!ira.uka.de!yale.edu!qt.cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!kong.gsfc.nasa.gov!arensb
From: arensb@kong.gsfc.nasa.gov (Andrew Arensburger - RMS)
Newsgroups: gnu.emacs.bug
Subject: Backspace and help bugs in Gnumacs 18.57
Message-ID: <9108202250.AA14480@kong.gsfc.nasa.gov>
Date: 20 Aug 91 22:50:01 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 250
Approved: bug-gnu-emacs@prep.ai.mit.edu