all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ben North" <ben@redfrontdoor.org>
Subject: last-sexp-toggle-display
Date: Fri, 4 Apr 2003 11:46:35 +0100 (IST)	[thread overview]
Message-ID: <55391.141.162.101.251.1049453195.squirrel@www.redfrontdoor.org> (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.

             reply	other threads:[~2003-04-04 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-04 10:46 Ben North [this message]
  -- 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55391.141.162.101.251.1049453195.squirrel@www.redfrontdoor.org \
    --to=ben@redfrontdoor.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.