2

I am using centered-cursor-mode to center the cursor at 10 lines above center at all times. I am trying to have ggtags respects this setup after each tag lookup.

When I have the cursor at any point on screen doing M-x recenter takes it to 10 lines above center. However, executing recenter inside a lambda doesn't have the same effect instead takes the cursor to the center.

This is my setup:

  (use-package centered-cursor-mode
    :ensure t
    :diminish 'centered-cursor-mode
    :init
    (defcustom ccm-vpos-init '(round (window-text-height) 2)
      "This is the screen line position where the cursor initially stays."
      :group 'centered-cursor
      :tag "Vertical cursor position"
      :type '(choice (const :tag "Center" (round (window-text-height) 2))
                     (const :tag "Golden ratio" (round (* 21 (window-text-height)) 34))
                     (integer :tag "Lines from top" :value 10)
                     (const :tag "10 Lines above center" (- (round (window-text-height) 2) 10))))
    ;; where the center line starts (change with C-M-0/-/+)
    (setq ccm-vpos-init (quote (- (round (window-text-height) 2) 10)))
    :config
    (global-centered-cursor-mode)
    (setq ccm-recenter-at-end-of-file  t    ;; recenter at end of file
          ccm-ignored-commands         '()  ;; Fixed hangs on big org files
          )
    (define-key ggtags-mode-map (kbd "M-.")
    (lambda ()
    (interactive)
    (call-interactively 'ggtags-find-tag-dwim)
    (recenter)))
)
2

This worked.

(add-hook 'ggtags-find-tag-hook #'ccm-position-cursor) 

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.