minad / consult

:mag: consult.el - Consulting completing-read
GNU General Public License v3.0
1.13k stars 99 forks source link

consult-xref broken in emacs 30 #1015

Closed fargiolas closed 2 weeks ago

fargiolas commented 2 weeks ago

Hi, not sure if it can be considered an issue as it's only broken in emacs master but it seems that consult-xref is failing with:

Wrong number of arguments: #<subr xref--group-name-for-display>, 2

since commit: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=b20d4ab374fb9b3c80b968df6acd6444f763bd40, function prototype changed and now takes an extra "dd" argument. Maybe it should be solved there making it optional?

kaiwk commented 2 weeks ago

A quick fix with el-patch can be:

;;  eval after consult-xref
(el-patch-defun consult-xref--candidates ()
  "Return xref candidate list."
  (let ((root (consult--project-root)))
    (mapcar (lambda (xref)
              (let* ((loc (xref-item-location xref))
                     (group (el-patch-swap (if (fboundp 'xref--group-name-for-display) ;;  <----- patch here
                                               ;; This function is available in xref 1.3.2
                                               (xref--group-name-for-display
                                                (xref-location-group loc) root)
                                             (xref-location-group loc))
                                           (xref-location-group loc)))
                     (cand (consult--format-file-line-match
                            group
                            (or (xref-location-line loc) 0)
                            (xref-item-summary xref))))
                (add-text-properties
                 0 1 `(consult-xref ,xref consult--prefix-group ,group) cand)
                cand))
            (funcall consult-xref--fetcher))))