Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm-locate doesn't highlight the searched pattern in the results #2710

Open
1 task done
taquangtrung opened this issue Feb 22, 2025 · 12 comments
Open
1 task done

Helm-locate doesn't highlight the searched pattern in the results #2710

taquangtrung opened this issue Feb 22, 2025 · 12 comments
Labels

Comments

@taquangtrung
Copy link
Contributor

What happened?

Hi,

I noticed that helm-locate doesn't highlight the searched pattern in the result.
Below is the screenshot, where the searched pattern mint wasn't highlighted in the located file names.

Image

I debugged a bit and found out that the field (filtered-candidate-transformer . helm-highlight-files) of helm-source-locate doesn't contain the transformer helm-fuzzy-highlight-matches like other Helm sources (see the attached image above).

Is it a bug or an intended behavior of helm-locate?
Can we support highlight matching patterns like in other Helm commands?

Thank you for spending time looking at this issue!

How to reproduce?

Run the command helm-locate, and type mint and see the result.

Helm Version

Master branch

Emacs Version

Emacs-29.1

OS

GNU/Linux

Relevant backtrace (if possible)


Minimal configuration

  • I agree using a minimal configuration
@thierryvolpiatto
Copy link
Member

I can't reproduce here, the matches are highlighted. Here the source while using helm-locate:

((name . "Locate") (init . helm-locate-initial-setup)
 (action . helm-type-file-actions)
 (persistent-action . helm-ff-kill-or-find-buffer-fname)
 (persistent-help . "Show this file")
 (help-message . helm-generic-file-help-message)
 (requires-pattern . 3)
 (candidate-transformer helm-skip-boring-files
                        helm-w32-pathname-transformer)
 (filtered-candidate-transformer helm-highlight-files
                                 helm-fuzzy-highlight-matches)
 (action-transformer helm-transform-file-load-el
                     helm-transform-file-browse-url
                     helm-transform-file-cache)
 (pattern-transformer . helm-locate-pattern-transformer)
 (candidate-number-limit . 9999)
 (redisplay . helm-locate-default-fuzzy-sort-fn)
 (history . helm-file-name-history)
[....]

From the helm-locate session, hit C-h d and paste the source here, thanks.

@taquangtrung
Copy link
Contributor Author

Hi @thierryvolpiatto, here is the debugging information obtained from C-h d:

* Helm debug from `*helm locate*' buffer

** Local variables

#+begin_src elisp
((buffer-undo-list . t)
 (cursor-type)
 (buffer-display-time 26553 49487 654481 260000)
 (left-margin-width . 0)
 (buffer-display-count . 3)
 (buffer-invisibility-spec . t)
 (buffer-file-truename)
 (point-before-scroll)
 (buffer-auto-save-file-format . t)
 (buffer-file-format)
 (enable-multibyte-characters . t)
 (mark-active)
 (truncate-lines)
 (local-abbrev-table .
		     [## 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0])
 (header-line-format .
		     #(" C-j: helm-ff-kill-or-find-buffer-fname (keeping session)                                                                                " 0 1
		       (face helm-header)
		       1 4
		       (face helm-header font-lock-face help-key-binding)
		       4 137
		       (face helm-header)))
 (mode-line-format :propertize
		   (" " mode-line-buffer-identification " "
		    (:eval
		     (format "L%-3d"
			     (helm-candidate-number-at-point)))
		    nil " "
		    (:eval nil)
		    (:eval
		     (when nil
		       (let
			   ((arg
			     (prefix-numeric-value
			      (or prefix-arg current-prefix-arg))))
			 (unless
			     (= arg 1)
			   (propertize
			    (format " [prefarg:%s]" arg)
			    'face 'helm-prefarg)))))
		    " "
		    (:eval
		     (with-helm-buffer
		       (helm-show-candidate-number
			(car-safe helm-mode-line-string))))
		    " " helm--mode-line-string-real " "
		    (:eval
		     (make-string
		      (window-width)
		      32)))
		   keymap
		   (keymap
		    (mode-line keymap
			       (mouse-1 . ignore)
			       (down-mouse-1 . ignore)
			       (drag-mouse-1 . ignore)
			       (mouse-2 . ignore)
			       (down-mouse-2 . ignore)
			       (drag-mouse-2 . ignore)
			       (mouse-3 . ignore)
			       (down-mouse-3 . ignore)
			       (drag-mouse-3 . ignore))))
 (mode-name . "Hmm")
 (local-minor-modes font-lock-mode)
 (major-mode . helm-major-mode)
 (buffer-read-only)
 (buffer-auto-save-file-name)
 (buffer-saved-size . 0)
 (buffer-backed-up)
 (default-directory . "/etc/init.d/")
 (buffer-file-name)
 (delay-mode-hooks)
 (current-input-method)
 (delayed-mode-hooks)
 (eldoc-mode-major-mode . helm-major-mode)
 (font-lock-mode . t)
 (char-property-alias-alist
  (face font-lock-face))
 (change-major-mode-hook font-lock-change-mode t)
 (font-lock-mode-set-explicitly . t)
 (font-lock-mode-major-mode . helm-major-mode)
 (delayed-after-hook-functions)
 (deactivate-mark . t)
 (helm-source-filter)
 (helm-display-function . helm-default-display-buffer)
 (helm-selection-point . 8)
 (scroll-margin . 0)
 (helm-marked-candidates)
 (helm--prompt . "pattern: ")
 (helm-persistent-action-display-window)
 (helm-async-outer-limit-hook #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_23>)
 (helm-ff-transformer-show-only-basename)
 (helm-visible-mark-overlays)
 (helm-input-local . "mint")
 (helm-mode-line-string "File(s)" "\\<helm-map>\\[helm-help]:Help \\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1..f12:NthAct \\[helm-toggle-suspend-update]:Tog.suspend \\[helm-customize-group]:Conf"))

#+end_src
** Value1
#+begin_src elisp
((name . "Locate")
 (init . helm-locate-initial-setup)
 (action . helm-type-file-actions)
 (persistent-action . helm-ff-kill-or-find-buffer-fname)
 (persistent-help . "Show this file")
 (help-message . helm-generic-file-help-message)
 (requires-pattern . 3)
 (candidate-transformer helm-skip-boring-files helm-w32-pathname-transformer)
 (filtered-candidate-transformer . helm-highlight-files)
 (action-transformer helm-transform-file-load-el helm-transform-file-browse-url helm-transform-file-cache)
 (pattern-transformer . helm-locate-pattern-transformer)
 (candidate-number-limit . 9999)
 (redisplay . helm-locate-default-fuzzy-sort-fn)
 (history . helm-file-name-history)
 (mode-line "File(s)" "\\<helm-map>\\[helm-help]:Help \\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1..f12:NthAct \\[helm-toggle-suspend-update]:Tog.suspend \\[helm-customize-group]:Conf")
 (header-line .
	      #("C-j: helm-ff-kill-or-find-buffer-fname (keeping session)" 0 3
		(font-lock-face help-key-binding face help-key-binding)))
 (match-part .
	     #[257 "\302�\303\304���\305$\266\203\204�\0	\203�\0\304\306�\"\204�\0\307�!\207\207"
		   [helm-pattern helm-locate-fuzzy-match " -b\\'" nil string-match t "\\s-" helm-basename]
		   9 "\n\n(fn CANDIDATE)"])
 (group . helm-locate)
 (candidates-process . helm-locate-init))

#+end_src

I use this minimal Emacs config:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Init straight

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name
        "straight/repos/straight.el/bootstrap.el"
        (or (bound-and-true-p straight-base-dir)
            user-emacs-directory)))
      (bootstrap-version 7))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Init Melpa

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Test some packages

;; helm
(use-package helm
  :straight t
  :config)

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 22, 2025 via email

@taquangtrung
Copy link
Contributor Author

taquangtrung commented Feb 22, 2025

I think I found the culprit. It might be due to the below code in helm-types.el

helm/helm-types.el

Lines 110 to 125 in 9fa8569

(cl-defmethod helm--setup-source :before ((source helm-type-file))
(setf (slot-value source 'action) 'helm-type-file-actions)
(setf (slot-value source 'persistent-help) "Show this file")
(setf (slot-value source 'action-transformer)
'(helm-transform-file-load-el
helm-transform-file-browse-url
helm-transform-file-cache))
(setf (slot-value source 'candidate-transformer)
'(helm-skip-boring-files
helm-w32-pathname-transformer))
(setf (slot-value source 'filtered-candidate-transformer)
'helm-highlight-files)
(setf (slot-value source 'help-message) 'helm-generic-file-help-message)
(setf (slot-value source 'mode-line) (list "File(s)" helm-mode-line-string))
(setf (slot-value source 'keymap) helm-generic-files-map)

I commented out lines 120, 121

  ;; (setf (slot-value source 'filtered-candidate-transformer)
  ;;       'helm-highlight-files)

Then helm-locate can highlight the matched patterns:

Image

I guess that 2 lines 120 and 121 override the settings done previously in helm-source?

helm/helm-source.el

Lines 1169 to 1174 in 9fa8569

(unless (slot-value source 'nohighlight)
(setf (slot-value source 'filtered-candidate-transformer)
(helm-aif (slot-value source 'filtered-candidate-transformer)
(append (helm-mklist it)
(list #'helm-fuzzy-highlight-matches))
(list #'helm-fuzzy-highlight-matches))))

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 22, 2025 via email

@taquangtrung
Copy link
Contributor Author

I tried both using emacs-helm.sh and emacs -q and manually installed helm. However, the same bug occurred.

I tested on Emacs 29.1 and 29.4.

@taquangtrung
Copy link
Contributor Author

taquangtrung commented Feb 22, 2025

I just upgraded my Emacs to 30.0.93 and how helm-locate can highlight the matching patterns correctly (see my screenshot).

It still baffles me why it doesn't work properly with Emacs 29.

Image

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 22, 2025 via email

thierryvolpiatto added a commit that referenced this issue Feb 22, 2025
This was needed in all previous Emacs versions, seems it is no more
needed on emacs-29, thus it confuse eieio, OTOH emacs-31 is perfectly
understanding this.
@thierryvolpiatto
Copy link
Member

Should be fixed, let me know if it is now highlighting candidates.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 22, 2025 via email

@taquangtrung
Copy link
Contributor Author

Thanks a lot for your effort!

It's working as expected on Emacs 29.4 now.

@thierryvolpiatto
Copy link
Member

thierryvolpiatto commented Feb 22, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants