Subject: Re: bug#19466: 25.0.50; xref-find-def doesn't find C functions

From: martin rudalics <[email-masked]>
Date: Wed, 21 Jan 2015 11:49:34 +0100

> Yeah, both should still work. I've pushed the buffer-killing implementation, please take a look.

The idea to do it via the KILL argument is good.  I think some
doc-strings are bad.  For example, instead of

(defvar-local xref--selected nil
   "t if the current buffer has ever been selected.
Used for temporary buffers.")

I'd say something like

(defvar-local xref--current nil
   "Non-nil if this buffer was current once while finding xrefs.")

And for `xref-quit' I'd describe the standard behavior first and the
KILL behavior afterwards.  Also I'm not sure it it's just cosmetics but
shouldn't the

     (pcase-dolist (`(,buf . ,win) history)
       (when (and (window-live-p win)
                  (eq buf (window-buffer win)))
         (quit-window nil win)))

precede the

     (when kill
       (let ((xref--inhibit-mark-selected t)
             kill-buffer-query-functions)
         (dolist (buf xref--temporary-buffers)
           (unless (buffer-local-value 'xref--selected buf)
             (kill-buffer buf)))
         (setq xref--temporary-buffers nil)))

part?  I can't test it currently because I always get

Debugger entered--Lisp error: (args-out-of-range "" 0)
   help-function-arglist(#[257 "\300\207" ["(No location)"] 2 "(No location)\n\n(fn ##)"] preserve-names)
   eieio--defmethod(xref-location-group nil xref-bogus-location #[257 "\300\207" ["(No location)"] 2 "(No location)\n\n(fn ##)"])
   byte-code("\300\301\302\301\303\"\"\210\304\301\303\305\306$\210\300\307\302\307\303\"\"\210\304\307\303\305\310$\207" [eieio--defalias xref-location-marker eieio--defgeneric-init-form nil eieio--defmethod xref-bogus-location #[257 "\300\301\302\303\"\"\207" [user-error "%s" eieio-oref :message] 6 "\n\n(fn L)"] xref-location-group #[257 "\300\207" ["(No location)"] 2 "(No location)\n\n(fn ##)"]] 5)
   autoload-do-load((autoload "xref" 1640080 t nil) xref-find-definitions)
   command-execute(xref-find-definitions)

even after a bootstrap.

 > One drawback comes to mind:
 >
 > xref-goto-xref calls xref-quit without the KILL argument, so the temporary buffers are not cleared if you make a choice and press RET.

You can redisplay the *xref* buffer and provide the KILL there.

 >> previous-/next-history-element
 >
 > Not sure what these are.

Something like typing M-. doing something else and typing M-. again.  At
this time up/down should get you the next/previous history elements of
your xref searches.

 > Depends on what you want each of them to do.
 >
 > debugger-mode should probably set both relevant vars to the same values as emacs-lisp-mode. help-mode and Custom-mode - maybe too, although they might use some custom logic.
 >
 > In Info-mode, xref-find-function could use the index and the search functionality.

Will there be a canonical way to add these?

martin