unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Stephen Berman <stephen.berman@gmx.net>
Cc: 4854@debbugs.gnu.org
Subject: bug#4854: 23.1.50; before-string overlay and show-paren-mode
Date: Sun, 03 Jul 2016 11:36:01 -0400	[thread overview]
Message-ID: <874m86g2e6.fsf@users.sourceforge.net> (raw)
In-Reply-To: <87r3ban653.fsf@gmx.net> (Stephen Berman's message of "Sun, 03 Jul 2016 16:33:12 +0200")

Stephen Berman <stephen.berman@gmx.net> writes:

> On Fri, 01 Jul 2016 14:42:30 -0400 npostavs@users.sourceforge.net wrote:
>
> [...]
>> Stephen Berman <stephen.berman@gmx.net> writes:
>>> These two things seem very strange: (i) enabling show-paren-mode and
>>> getting the show-paren overlay somehow nullifies the unless test; (ii)
>>> this effect only happens when the command is invoked via a key
>>> sequence.
>>
>> It's because show-paren-mode uses a single (pair of) overlay(s) for all
>> buffers and moves it to right place during idle time.  When you invoke a
>> command with M-x the overlay pair gets moved to the minibuffer.  With a
>> direct keybinding the overlay pair stays in the current buffer.
>
> Thanks for the diagnosis, which is convincing.
>
>> So I think this is not a bug, it's just how show-paren-mode works.
>
> I guess you're right; yet this behavior seems to go against the spirit
> of the way Emacs is intended to work, as suggested by the Emacs manual,
> node `M-x': "Every Emacs command has a name that you can use to run it.
> For convenience, many commands also have key bindings.  You can run
> those commands by typing the keys, or run them by name.  Most Emacs
> commands have no key bindings, so the only way to run them is by
> name. [...]  Note that ‘forward-char’ is the same command that you
> invoke with the key ‘C-f’.  The existence of a key binding does not stop
> you from running the command by name."  Are there any other Emacs
> commands that produce different behavior depending on whether they are
> invoked with a key binding or by name?

self-insert-command ;)

You can fix your my-test command by changing the condition:

(defun my-test ()
  ...
  (unless (cl-some (lambda (o) (overlay-get o 'before-string))
                   (overlays-in (1- (point)) (1+ (point))))
    ...))

>                                         
>                                         Maybe it would be better to
> unify the behavior of show-paren-mode.  (I briefly tried conditioning
> the calls to move-overlay on whether the current buffer is a minibuffer,
> but my attempt (which I didn't give much thought to) didn't work.)

Well, it's possible to avoid moving overlays to minibuffer, but then
show-paren-mode stops working in the minibuffer, which I don't think is
so great.

diff --git i/lisp/paren.el w/lisp/paren.el
index 53eb500..1e4942f 100644
--- i/lisp/paren.el
+++ w/lisp/paren.el
@@ -236,9 +236,10 @@ show-paren--default
 ;; Find the place to show, if there is one,
 ;; and show it until input arrives.
 (defun show-paren-function ()
-  (let ((data (and show-paren-mode (funcall show-paren-data-function))))
+  (let ((data (and show-paren-mode (not (minibufferp))
+                   (funcall show-paren-data-function))))
     (if (not data)
-        (progn
+        (unless (minibufferp)
           ;; If show-paren-mode is nil in this buffer or if not at a paren that
           ;; has a match, turn off any previous paren highlighting.
           (delete-overlay show-paren--overlay)

With that patch, the original my-test keeps inserting more overlays
whether it's called by keybinding or M-x.

>
> I guess this bug can be closed, unless leaving it open might spur
> someone to try and "improve" show-paren-mode.

Not sure if there's anything to do.





  reply	other threads:[~2016-07-03 15:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-02 14:49 bug#4854: 23.1.50; before-string overlay and show-paren-mode Stephen Berman
2009-11-04 23:08 ` Stephen Berman
2016-07-01 18:42   ` npostavs
2016-07-03 14:33     ` Stephen Berman
2016-07-03 15:36       ` npostavs [this message]
2016-07-03 15:42         ` Eli Zaretskii
2016-07-03 15:58           ` npostavs
2016-07-03 22:23             ` Stephen Berman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=874m86g2e6.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=4854@debbugs.gnu.org \
    --cc=stephen.berman@gmx.net \
    /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 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).