Skip to main content
Fix minibuffer bug
Source Link
ahilsend
  • 1.5k
  • 11
  • 8

But this won't flash on buffer/framewindow switches, unfortunately there are no hooks for that. But at least emacs lisp gives us advising functions, which allow us to extend existing functions. Though that can be quite tricky.

This will flash the crosshair after window/bufferbuffer switches:

(defadvice selectswitch-windowto-buffer (after selectswitch-windowto-buffer-flash-crosshairs activate)
  "Call `flash-crosshairs' after `switch-to-buffer'"
  (flash-crosshairs))

This should work in most cases (when the switch is done without switch-to-buffer)

The window switch is more difficult, since minibuffers (open file etc.) cause some issues. So only flash when we switch to another buffer:

(defadvice switchselect-window (around select-window-flash-crosshairs activate)
  "Call `flash-crosshairs' after `select-window', if switching to another buffer.
The check is necessary to prevent issues with mini-buffer switching."
  (let (cons (cur-buffer-name (afterbuffer-name switch(current-tobuffer)))
             ad-arg-bindings)
    ad-do-it
    (unless (string= (buffer-flashname (window-crosshairsbuffer activatewindow))
                     cur-buffer-name)
      (flash-crosshairs))))

ad-arg-bindings are the arguments to the advised function and ad-do-it executes the original.

To deactivate the advices use:

(ad-remove-advice 'select-window 'after'around 'select-window-flash-crosshairs)
(ad-remove-advice 'switch-to-buffer 'after 'switch-to-buffer-flash-crosshairs)

I think that covers most cases, though like I said advising is tricky ...

But this won't flash on buffer/frame switches, unfortunately there are no hooks for that. But at least emacs lisp gives us advising functions, which allow us to extend existing functions.

This will flash the crosshair after window/buffer switches:

(defadvice select-window (after select-window-flash-crosshairs activate)
  (flash-crosshairs))
(defadvice switch-to-buffer (after switch-to-buffer-flash-crosshairs activate)
  (flash-crosshairs))

To deactivate the advices use:

(ad-remove-advice 'select-window 'after 'select-window-flash-crosshairs)
(ad-remove-advice 'switch-to-buffer 'after 'switch-to-buffer-flash-crosshairs)

But this won't flash on buffer/window switches, unfortunately there are no hooks for that. But at least emacs lisp gives us advising functions, which allow us to extend existing functions. Though that can be quite tricky.

This will flash the crosshair after buffer switches:

(defadvice switch-to-buffer (after switch-to-buffer-flash-crosshairs activate)
  "Call `flash-crosshairs' after `switch-to-buffer'"
  (flash-crosshairs))

This should work in most cases (when the switch is done without switch-to-buffer)

The window switch is more difficult, since minibuffers (open file etc.) cause some issues. So only flash when we switch to another buffer:

(defadvice select-window (around select-window-flash-crosshairs activate)
  "Call `flash-crosshairs' after `select-window', if switching to another buffer.
The check is necessary to prevent issues with mini-buffer switching."
  (let (cons (cur-buffer-name (buffer-name (current-buffer)))
             ad-arg-bindings)
    ad-do-it
    (unless (string= (buffer-name (window-buffer window))
                     cur-buffer-name)
      (flash-crosshairs))))

ad-arg-bindings are the arguments to the advised function and ad-do-it executes the original.

To deactivate the advices use:

(ad-remove-advice 'select-window 'around 'select-window-flash-crosshairs)
(ad-remove-advice 'switch-to-buffer 'after 'switch-to-buffer-flash-crosshairs)

I think that covers most cases, though like I said advising is tricky ...

Flash crosshairs
Source Link
ahilsend
  • 1.5k
  • 11
  • 8

I find it helps to have emacs highlight the current line. The minor mode hl-line-mode does that. You can enable it in your current buffer with M-x hl-line-mode, or globally from your emacs config:

(global-hl-line-mode 1)

Take a look at the Emacswiki: HighlightCurrentLine. It also mentions other minor-modes that might be more in your interest.


Edit:

While looking through the wiki myself I found the crosshairs-mode. I think I'll try it out myself:

(crosshairs-mode 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)

Edit2:

I like the horizontal line, but I find the constant vertical line distracting. Luckily crosshairs also provides a flash function flash-crosshairs and an idle mode toggle-crosshairs-when-idle.

To display the crosshair on idle I have this in my config:

(require 'crosshairs)
(toggle-crosshairs-when-idle 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)

But this won't flash on buffer/frame switches, unfortunately there are no hooks for that. But at least emacs lisp gives us advising functions, which allow us to extend existing functions.

This will flash the crosshair after window/buffer switches:

(defadvice select-window (after select-window-flash-crosshairs activate)
  (flash-crosshairs))
(defadvice switch-to-buffer (after switch-to-buffer-flash-crosshairs activate)
  (flash-crosshairs))

To deactivate the advices use:

(ad-remove-advice 'select-window 'after 'select-window-flash-crosshairs)
(ad-remove-advice 'switch-to-buffer 'after 'switch-to-buffer-flash-crosshairs)

I find it helps to have emacs highlight the current line. The minor mode hl-line-mode does that. You can enable it in your current buffer with M-x hl-line-mode, or globally from your emacs config:

(global-hl-line-mode 1)

Take a look at the Emacswiki: HighlightCurrentLine. It also mentions other minor-modes that might be more in your interest.


While looking through the wiki myself I found the crosshairs-mode. I think I'll try it out myself:

(crosshairs-mode 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)

I find it helps to have emacs highlight the current line. The minor mode hl-line-mode does that. You can enable it in your current buffer with M-x hl-line-mode, or globally from your emacs config:

(global-hl-line-mode 1)

Take a look at the Emacswiki: HighlightCurrentLine. It also mentions other minor-modes that might be more in your interest.


Edit:

While looking through the wiki myself I found the crosshairs-mode. I think I'll try it out myself:

(crosshairs-mode 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)

Edit2:

I like the horizontal line, but I find the constant vertical line distracting. Luckily crosshairs also provides a flash function flash-crosshairs and an idle mode toggle-crosshairs-when-idle.

To display the crosshair on idle I have this in my config:

(require 'crosshairs)
(toggle-crosshairs-when-idle 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)

But this won't flash on buffer/frame switches, unfortunately there are no hooks for that. But at least emacs lisp gives us advising functions, which allow us to extend existing functions.

This will flash the crosshair after window/buffer switches:

(defadvice select-window (after select-window-flash-crosshairs activate)
  (flash-crosshairs))
(defadvice switch-to-buffer (after switch-to-buffer-flash-crosshairs activate)
  (flash-crosshairs))

To deactivate the advices use:

(ad-remove-advice 'select-window 'after 'select-window-flash-crosshairs)
(ad-remove-advice 'switch-to-buffer 'after 'switch-to-buffer-flash-crosshairs)
Add crosshairs mode description
Source Link
ahilsend
  • 1.5k
  • 11
  • 8

I find it helps to have emacs highlight the current line. The minor mode hl-line-mode does that. You can enable it in your current buffer with M-x hl-line-mode, or globally from your emacs config:

(global-hl-line-mode 1)

Take a look at the Emacswiki: HighlightCurrentLine. It also mentions other minor-modes that might be more in your interest.


While looking through the wiki myself I found the crosshairs-mode. I think I'll try it out myself:

(crosshairs-mode 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)

I find it helps to have emacs highlight the current line. The minor mode hl-line-mode does that. You can enable it in your current buffer with M-x hl-line-mode, or globally from your emacs config:

(global-hl-line-mode 1)

Take a look at the Emacswiki: HighlightCurrentLine. It also mentions other minor-modes that might be more in your interest.

I find it helps to have emacs highlight the current line. The minor mode hl-line-mode does that. You can enable it in your current buffer with M-x hl-line-mode, or globally from your emacs config:

(global-hl-line-mode 1)

Take a look at the Emacswiki: HighlightCurrentLine. It also mentions other minor-modes that might be more in your interest.


While looking through the wiki myself I found the crosshairs-mode. I think I'll try it out myself:

(crosshairs-mode 1)
(setq col-highlight-vline-face-flag  t
      col-highlight-face             hl-line-face)
Source Link
ahilsend
  • 1.5k
  • 11
  • 8
Loading