During the i-search if I use dracula theme it highlights the line-number if the searched word is the first in the line.

Example view:

enter image description here

If I uncomment (load-theme 'dracula t) the example view would be where line number is not highlighted:

enter image description here

==> I just want to disable the highlight option for line numbers for a specific theme, is it possible? How to discard line-number highlight during i-search?

my setup:

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'dracula t)

(setq linum-format "%d ")
(add-hook 'isearch-mode-hook (lambda () (linum-mode 1)))
(add-hook 'isearch-mode-end-hook (lambda () (linum-mode 0)))
(delete-selection-mode 1) ;; Overwrite selected text

(define-key isearch-mode-map (kbd "C-w") 'isearch-forward-symbol-at-point)

(defadvice isearch-repeat (after isearch-no-fail activate)
  (unless isearch-success
    (ad-disable-advice 'isearch-repeat 'after 'isearch-no-fail)
    (ad-activate 'isearch-repeat)
    (isearch-repeat (if isearch-forward 'forward))
    (ad-enable-advice 'isearch-repeat 'after 'isearch-no-fail)
    (ad-activate 'isearch-repeat)))

(define-advice isearch-repeat (:before (direction) goto-other-end)
  "If reversing, start the search from the other end of the current match."
  (unless (eq isearch-forward (eq direction 'forward))
    (when isearch-other-end
      (goto-char isearch-other-end))))
  • Why are you using linum-mode, instead of the built-in line numbers that Eli Z. implemented starting from Emacs 26 and forwards? linum-mode is officially deprecated. The replacement is display-line-numbers-mode / global-display-line-numbers-mode: gnu.org/software/emacs/manual/html_node/emacs/… – lawlist Mar 15 at 5:41
  • I was using linum-mode due to this answer emacs.stackexchange.com/a/59844/18414 , should I change linum-mode with display-line-numbers-mode ? – alper Mar 15 at 8:25
  • 1
    For buffers with not too many lines, the performance will not make a difference. For buffers with many lines and/or folded (invisible) lines, the performance hit will be noticeable. Some forum participants may hesitate to write-up an answer that relies upon a feature that has been deprecated. The slow-down in performance is that linum-mode relies upon count-lines, which is slow in longer buffers. The built-in line number written by Eli Z. does not rely upon count-lines and lines numbers are drawn during redisplay and prepended to the display line. linum-mode uses overlays / margin – lawlist Mar 16 at 0:43
  • @lawlist Thanks changing linum-mode into display-line-numbers-mode fixed the issue – alper Mar 17 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.