* Re: disable-command twice adds blank lines
2005-04-23 16:15 ` Richard Stallman
@ 2005-04-26 9:13 ` Lute Kamstra
0 siblings, 0 replies; 3+ messages in thread
From: Lute Kamstra @ 2005-04-26 9:13 UTC (permalink / raw)
Cc: bug-gnu-emacs, Dan Jacobson
Richard Stallman <rms@gnu.org> writes:
> This did not fail for me in the current version.
I did for me. Here is how you can reproduce it:
Start Emacs and visit your .emacs.
Make sure the end of the buffer is visible.
Do: M-: (disable-command 'not-modified) RET
This inserts "\n(put 'not-modified 'disabled t)\n" at (point-max).
Do another: M-: (disable-command 'not-modified) RET
This inserts "\n" before the "(put 'not-modified 'disabled t)" at
the end of the buffer.
The problem is that disable-command first deletes _one_ existing line
with "(put 'not-modified " in it and then inserts _two_ new lines.
The net result is inserting one newline. What about the patch below
to fix this? It has the side effect of inserting a new "(put
'not-modified " sexp at the location it deleted an old one, which is
good IMO.
Lute.
Index: lisp/novice.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/novice.el,v
retrieving revision 1.38
diff -c -r1.38 novice.el
*** lisp/novice.el 6 Mar 2005 18:29:10 -0000 1.38
--- lisp/novice.el 26 Apr 2005 09:03:03 -0000
***************
*** 1,6 ****
;;; novice.el --- handling of disabled commands ("novice mode") for Emacs
! ;; Copyright (C) 1985, 1986, 1987, 1994, 2002, 2004
;; Free Software Foundation, Inc.
;; Maintainer: FSF
--- 1,6 ----
;;; novice.el --- handling of disabled commands ("novice mode") for Emacs
! ;; Copyright (C) 1985, 1986, 1987, 1994, 2002, 2004, 2005
;; Free Software Foundation, Inc.
;; Maintainer: FSF
***************
*** 182,190 ****
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region
(progn (beginning-of-line) (point))
! (progn (forward-line 1) (point))))
! (goto-char (point-max))
! (insert "\n(put '" (symbol-name command) " 'disabled t)\n")
(save-buffer))))
(provide 'novice)
--- 182,191 ----
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
(delete-region
(progn (beginning-of-line) (point))
! (progn (forward-line 1) (point)))
! (goto-char (point-max))
! (insert ?\n))
! (insert "(put '" (symbol-name command) " 'disabled t)\n")
(save-buffer))))
(provide 'novice)
^ permalink raw reply [flat|nested] 3+ messages in thread