From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Daniel E. Doherty" Newsgroups: gmane.emacs.help Subject: Re: change cursor type Date: Fri, 06 Dec 2013 07:38:45 -0600 Organization: A noiseless patient Spider Message-ID: <87y53yt7yy.fsf@ddoherty.net> References: <41194d17-7423-4b72-9ccf-22f98d9d50a2@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1386338757 16398 80.91.229.3 (6 Dec 2013 14:05:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Dec 2013 14:05:57 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 06 15:06:03 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vow2d-0008HB-10 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Dec 2013 15:06:03 +0100 Original-Received: from localhost ([::1]:59161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vow2c-0000ig-C8 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Dec 2013 09:06:02 -0500 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 45 Injection-Info: mx05.eternal-september.org; posting-host="fe65844d9228e020ffac2aff67a17ab6"; logging-data="16808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pMrF+4QSLGJZwsdDP9LmmDTq4n0yImgQ=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:YZakoD0f7qUhkoQDRUAtU22Dprg= sha1:0Izd/yc2c5bVnBGQw7VxFGjZ45w= Original-Xref: usenet.stanford.edu gnu.emacs.help:202584 X-Mailman-Approved-At: Fri, 06 Dec 2013 09:05:44 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94852 Archived-At: 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