1

I would like to recenter current line after jumping by using helm-semantic-or-imenu or helm-org-in-buffer-headings, i.e., just like helm-swoop. Is it possible?

Community
  • 1
  • 1
AhLeung
  • 207
  • 1
  • 5

1 Answers1

1

I don't use helm, but I do this for isearch. Figure out which function actually jumps to a line (maybe the called function, e.g. helm-semantic-or-imenu, maybe some internal helper function as is the case for isearch), then add the following advice to it.

(defun recenter-no-redraw (&optional arg)
  "Like `recenter', but no redrawing."
  (interactive "P")
  (let ((recenter-redisplay nil))
    (recenter arg)))

(advice-add 'isearch-search
            :after
            (lambda (&rest args)
              "Recenter"
              (when isearch-success
                (recenter-no-redraw))))

I can't remember why I defined a non-redrawing version of recenter (I've had it like that for years). It should work with plain recenter also.

jpkotta
  • 9,237
  • 3
  • 29
  • 34
  • 1
    It works! I used: `(advice-add 'helm-semantic-or-imenu :after (lambda (&rest args) (recenter-no-redraw)))` Thanks! – AhLeung Apr 29 '16 at 16:00