all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Juri Linkov <juri@linkov.net>
Cc: 35737@debbugs.gnu.org
Subject: bug#35737: xref--original-command
Date: Tue, 28 May 2019 02:21:45 +0300	[thread overview]
Message-ID: <3adebd17-70e5-712d-ba78-6e3aa884cfa6@yandex.ru> (raw)
In-Reply-To: <413fa232-ea7f-bd6a-ecce-632962a7f57e@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

To be clear, here's the kind of change I was thinking of.

Though maybe instead of changing xref--show-defs-buffer, we'd add a new 
function named like xref--show-defs-buffer-below.

[-- Attachment #2: xref-find-definitions-at-bottom.diff --]
[-- Type: text/x-patch, Size: 3051 bytes --]

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 58c0119a54..80f80cdd75 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -704,6 +704,16 @@ xref--xref-buffer-mode
   (setq next-error-function #'xref--next-error-function)
   (setq next-error-last-buffer (current-buffer)))
 
+(defvar xref--definitions-buffer-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "RET") #'xref-quit-and-goto-xref)
+    (set-keymap-parent map xref--xref-buffer-mode-map)
+    map))
+
+(define-derived-mode xref--definitions-buffer-mode
+  xref--xref-buffer-mode
+  "XREF Defs")
+
 (defun xref--next-error-function (n reset?)
   (when reset?
     (goto-char (point-min)))
@@ -725,7 +735,6 @@ xref--next-error-function
 
 (defvar xref--button-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [(control ?m)] #'xref-goto-xref)
     (define-key map [mouse-1] #'xref-goto-xref)
     (define-key map [mouse-2] #'xref--mouse-2)
     map))
@@ -789,18 +798,21 @@ xref--show-xref-buffer
            (funcall fetcher)))
          (xref-alist (xref--analyze xrefs)))
     (with-current-buffer (get-buffer-create xref-buffer-name)
-      (setq buffer-undo-list nil)
-      (let ((inhibit-read-only t)
-            (buffer-undo-list t))
-        (erase-buffer)
-        (xref--insert-xrefs xref-alist)
-        (xref--xref-buffer-mode)
-        (pop-to-buffer (current-buffer))
-        (goto-char (point-min))
-        (setq xref--original-window (assoc-default 'window alist)
-              xref--original-window-intent (assoc-default 'display-action alist))
-        (setq xref--fetcher fetcher)
-        (current-buffer)))))
+      (xref--show-common-initialize xref-alist fetcher alist)
+      (xref--xref-buffer-mode)
+      (pop-to-buffer (current-buffer))
+      (current-buffer))))
+
+(defun xref--show-common-initialize (xref-alist fetcher alist)
+  (setq buffer-undo-list nil)
+  (let ((inhibit-read-only t)
+        (buffer-undo-list t))
+    (erase-buffer)
+    (xref--insert-xrefs xref-alist)
+    (goto-char (point-min))
+    (setq xref--original-window (assoc-default 'window alist)
+          xref--original-window-intent (assoc-default 'display-action alist))
+    (setq xref--fetcher fetcher)))
 
 (defun xref-refresh-results ()
   "Refresh the search results in the current buffer."
@@ -826,9 +838,12 @@ xref--show-defs-buffer
       (xref--pop-to-location (car xrefs)
                              (assoc-default 'display-action alist)))
      (t
-      (xref--show-xref-buffer fetcher
-                              (cons (cons 'fetched-xrefs xrefs)
-                                    alist))))))
+      (with-current-buffer (get-buffer-create xref-buffer-name)
+        (xref--show-common-initialize (xref--analyze xrefs) fetcher alist)
+        (xref--definitions-buffer-mode)
+        (pop-to-buffer (current-buffer)
+                       '(display-buffer-in-direction . ((direction . below))))
+        (current-buffer))))))
 
 \f
 (defvar xref-show-xrefs-function 'xref--show-xref-buffer

  reply	other threads:[~2019-05-27 23:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14 20:53 bug#35737: xref--original-command Juri Linkov
2019-05-15  1:07 ` Dmitry Gutov
2019-05-15 21:04   ` Juri Linkov
2019-05-15 22:30     ` Dmitry Gutov
2019-05-16 19:58       ` Juri Linkov
2019-05-24  1:59         ` Dmitry Gutov
2019-05-24 18:40           ` Juri Linkov
2019-05-24 22:48             ` Dmitry Gutov
2019-05-27 19:59               ` Juri Linkov
2019-05-27 21:13                 ` Dmitry Gutov
2019-05-27 23:21                   ` Dmitry Gutov [this message]
2019-05-28  2:41                   ` Eli Zaretskii
2019-05-28  7:46                     ` Dmitry Gutov
2019-05-28 15:01                       ` Eli Zaretskii
2019-05-28 20:30                   ` Juri Linkov
2019-05-30 17:33                     ` Dmitry Gutov
2019-06-09 23:44                     ` Dmitry Gutov

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=3adebd17-70e5-712d-ba78-6e3aa884cfa6@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=35737@debbugs.gnu.org \
    --cc=juri@linkov.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 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.