bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: disable-command twice adds blank lines


From: Lute Kamstra
Subject: Re: disable-command twice adds blank lines
Date: Tue, 26 Apr 2005 11:13:24 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> 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)




reply via email to

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