[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
last-sexp-toggle-display
From: |
Ben North |
Subject: |
last-sexp-toggle-display |
Date: |
Fri, 4 Apr 2003 11:46:35 +0100 (IST) |
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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- last-sexp-toggle-display,
Ben North <=