unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* last-sexp-toggle-display
@ 2003-04-04 10:46 Ben North
  0 siblings, 0 replies; 7+ messages in thread
From: Ben North @ 2003-04-04 10:46 UTC (permalink / raw)


I came across two problems with `last-sexp-toggle-display':

1) Replaces wrong text if called when point before first
   character of togglable text, and a previous block of
   togglable text exists in the buffer.

To reproduce:

Start up fresh "emacs -q".  In *scratch*, type

(make-list 20 'a)[C-j]
(make-list 20 'b)[C-j]

You now should be looking at

(make-list 20 'a)
(a a a a a a a a a a a a ...)
(make-list 20 'b)
(b b b b b b b b b b b b ...)
-!-

Press C-p to move to "(" at start of "b" list:

(make-list 20 'a)
(a a a a a a a a a a a a ...)
(make-list 20 'b)
-!-(b b b b b b b b b b b b ...)

Press RET to call `last-sexp-toggle-display'.  You get

(make-list 20 'a)
(a a a a a a a a a a a a ...)(b b b b b b b b b -!-b b b b b b b b b b b)

which is not what you want.  This patch to CVS' lisp-mode.el
fixes this:


--- ORIG--lisp-mode.el  2003-04-04 11:10:58.000000000 +0100
+++ lisp-mode.el        2003-04-04 11:14:56.000000000 +0100
@@ -424,7 +424,9 @@
   (interactive)
   (let ((value (get-text-property (point) 'printed-value)))
     (when value
-      (let ((beg (or (previous-single-property-change (point) 'printed-value) (point)))
+      (let ((beg (or (previous-single-property-change (min (point-max) (1+ (point)))
+                                                      'printed-value)
+                     (point)))
            (end (or (next-single-char-property-change (point) 'printed-value) (point)))
            (standard-output (current-buffer))
            (point (point)))


(The `min' stuff may be unnecessary, but next problem is loosely
related.)

2) RET does nothing at (point-max) if togglable text extends to
   the very end of a buffer.

To reproduce:

In a fresh emacs, in *scratch*, type

(make-list 20 'a)[C-j]

to get

(make-list 20 'a)
(a a a a a a a a a a a a ...)
-!-

Press DEL to erase the final newline in the buffer, leaving you
with

(make-list 20 'a)
(a a a a a a a a a a a a ...)-!-

(and point at the end of the buffer).  Press RET.  Nothing
happens.

I don't have a fix for this one, but it is happening because at
the very end of a buffer, there is no character after point.
But Emacs looks up keypresses in the previous character's
`keymap' text property --- this is explicitly mentioned in
get_local_map() in intervals.c.  The previous character has a
`keymap' property mapping RET to `last-sexp-toggle-display',
which does

   (get-text-property (point) 'printed-value)

and finds nothing, because there is no character after point, so
`get-text-property' returns nil.

This inconsistency is what causes the confusion: get_local_map()
handles the case of (point-max) specially, but
`get-text-property' doesn't.  I must admit that this behaviour
of get_local_map() seems a bit strange to me, but of course I
looked at it for the first time just now so have no idea how
much code depends on this behaviour.  Perhaps somebody else can
suggest a fix to this second problem?

Thanks,

Ben.

^ permalink raw reply	[flat|nested] 7+ messages in thread
* last-sexp-toggle-display
@ 2003-08-07  6:04 Richard Stallman
  2003-08-07 16:56 ` last-sexp-toggle-display Luc Teirlinck
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2003-08-07  6:04 UTC (permalink / raw)


What would people think of putting last-sexp-toggle-display in Lisp modes
on M-RET instead of on RET?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-08-12 23:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-04 10:46 last-sexp-toggle-display Ben North
  -- strict thread matches above, loose matches on Subject: below --
2003-08-07  6:04 last-sexp-toggle-display Richard Stallman
2003-08-07 16:56 ` last-sexp-toggle-display Luc Teirlinck
2003-08-11 12:53   ` last-sexp-toggle-display Richard Stallman
2003-08-11 17:59     ` last-sexp-toggle-display Luc Teirlinck
2003-08-12 23:21       ` last-sexp-toggle-display Richard Stallman
2003-08-12 23:22       ` last-sexp-toggle-display Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).