[Top][All Lists]

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

bug#34908: Push mark in xref-push-marker-stack

From: Juri Linkov
Subject: bug#34908: Push mark in xref-push-marker-stack
Date: Wed, 20 Mar 2019 23:59:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> I'm not sure where to call push-mark: closer to the command,
>> or closer to ring-insert.  It seems a suitable place for
>> push-mark is in xref-push-marker-stack as its name suggests.
> I'd rather have a more localized change, at least for now. And leave
> xref-push-marker-stack to only modify its own data structure.

Do you think other commands that use xref-push-marker-stack
won't need setting the mark?

> So how about this?
> diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
> index 6974d00048..015ea16f34 100644
> --- a/lisp/progmodes/xref.el
> +++ b/lisp/progmodes/xref.el
> @@ -797,6 +797,7 @@ xref--read-identifier-history
>  (defvar xref--read-pattern-history nil)
>  (defun xref--show-xrefs (xrefs display-action &optional always-show-list)
> +  (push-mark nil t)

push-mark is usually called closer to the end of the command.

>    (cond
>     ((and (not (cdr xrefs)) (not always-show-list))
>      (xref-push-marker-stack)

Some commands like e.g. ‘goto-line’ use such idiom:

  (or (region-active-p) (push-mark))

documented in its docstring as

  Prior to moving point, this function sets the mark (without
  activating it), unless Transient Mark mode is enabled and the
  mark is already active.

reply via email to

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