[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: change cursor type
From: |
Daniel E. Doherty |
Subject: |
Re: change cursor type |
Date: |
Fri, 06 Dec 2013 07:38:45 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Here is what I have in my init file to change cursor type and color based on
the mode. This is an org-mode init, so just the SRC blocks. It's all cribbed
from Dirk-Jan C. Binnema, but the link to Emacs Wiki is broken.
** Cursor Change cursor color according to mode; inspired by
[[http://www.emacswiki.orgemacs/ChangingCursorDynamically][Wiki Article]].
Valid values for "cursor type" are explained at
[[info:emacs#Cursor%20Display][Cursor Display]] in the manual.
#+BEGIN_SRC emacs-lisp :tangle yes
(setq djcb-read-only-color "red")
(setq djcb-read-only-cursor-type '(hbar . 5))
(setq djcb-overwrite-color "yellow")
(setq djcb-overwrite-cursor-type 'box)
(setq djcb-normal-color "green")
(setq djcb-normal-cursor-type '(bar . 5))
(blink-cursor-mode 1)
#+END_SRC
Define function to change the cursor type according to the current
mode.
#+BEGIN_SRC emacs-lisp :tangle yes
(defun djcb-set-cursor-according-to-mode ()
"Change cursor color and type according to some minor modes."
(cond
(buffer-read-only
(set-cursor-color djcb-read-only-color)
(setq cursor-type djcb-read-only-cursor-type))
(overwrite-mode
(set-cursor-color djcb-overwrite-color)
(setq cursor-type djcb-overwrite-cursor-type))
(t
(set-cursor-color djcb-normal-color)
(setq cursor-type djcb-normal-cursor-type))))
#+END_SRC
And call it after each command is run.
#+BEGIN_SRC emacs-lisp :tangle yes
(add-hook 'post-command-hook 'djcb-set-cursor-according-to-mode)
#+END_SRC
--
====================================================
Daniel E. Doherty
- Re: change cursor type,
Daniel E. Doherty <=