From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: change cursor type when idle Date: Mon, 28 Aug 2006 23:44:06 +0200 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1156801556 31102 80.91.229.2 (28 Aug 2006 21:45:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2006 21:45:56 +0000 (UTC) Cc: Emacs-Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 28 23:45:53 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GHovH-0007Kl-Qi for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2006 23:45:36 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHovH-0007V8-9V for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2006 17:45:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GHov4-0007Uc-CY for emacs-devel@gnu.org; Mon, 28 Aug 2006 17:45:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GHov2-0007TZ-Jp for emacs-devel@gnu.org; Mon, 28 Aug 2006 17:45:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHov2-0007TW-HO for emacs-devel@gnu.org; Mon, 28 Aug 2006 17:45:20 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GHp44-0000li-Ee for emacs-devel@gnu.org; Mon, 28 Aug 2006 17:54:40 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id CF9878A004A; Mon, 28 Aug 2006 23:45:17 +0200 (CEST) Original-To: "Drew Adams" In-Reply-To: (Kim F. Storm's message of "Mon, 28 Aug 2006 11:54:08 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59024 Archived-At: storm@cua.dk (Kim F. Storm) writes: > If people don't like a blinking cursor normally, they just have to define > blink-cursor-delay to the same value as blink-cursor-idle-cursor-delay. Here is a version that does this correctly. If people just wants the cursor type to change after, say, 3 seconds, but don't want a blinking cursor, do: (setq cursor-type 'bar blink-cursor-delay 3.0 blink-cursor-idle-cursor-delay blink-cursor-delay blink-cursor-interval 10e7) *** frame.el 22 Aug 2006 08:59:52 +0200 1.239 --- frame.el 28 Aug 2006 23:37:26 +0200 *************** *** 1244,1249 **** --- 1244,1261 ---- :type 'number :group 'cursor) + (defcustom blink-cursor-idle-cursor-delay 5.0 + "*Seconds of idle time after which cursor changes shape." + :type 'number + :version "22.1" + :group 'cursor) + + (defcustom blink-cursor-idle-cursor-type 'box + "*Type of cursor which idle cursor changes shape into." + :type 'number + :version "22.1" + :group 'cursor) + (defvar blink-cursor-idle-timer nil "Timer started after `blink-cursor-delay' seconds of Emacs idle time. The function `blink-cursor-start' is called when the timer fires.") *************** *** 1253,1258 **** --- 1265,1273 ---- This timer calls `blink-cursor-timer-function' every `blink-cursor-interval' seconds.") + (defvar blink-cursor-saved-cursor-type nil + "Saved type of cursor if changed.") + (defun blink-cursor-start () "Timer function called from the timer `blink-cursor-idle-timer'. This starts the timer `blink-cursor-timer', which makes the cursor blink *************** *** 1261,1275 **** (when (null blink-cursor-timer) ;; Set up the timer first, so that if this signals an error, ;; blink-cursor-end is not added to pre-command-hook. ! (setq blink-cursor-timer (run-with-timer blink-cursor-interval blink-cursor-interval ! 'blink-cursor-timer-function)) (add-hook 'pre-command-hook 'blink-cursor-end) ! (internal-show-cursor nil nil))) ! (defun blink-cursor-timer-function () "Timer function of timer `blink-cursor-timer'." ! (internal-show-cursor nil (not (internal-show-cursor-p)))) (defun blink-cursor-end () "Stop cursor blinking. --- 1276,1299 ---- (when (null blink-cursor-timer) ;; Set up the timer first, so that if this signals an error, ;; blink-cursor-end is not added to pre-command-hook. ! (setq blink-cursor-saved-cursor-type nil ! blink-cursor-timer (run-with-timer blink-cursor-interval blink-cursor-interval ! 'blink-cursor-timer-function t)) (add-hook 'pre-command-hook 'blink-cursor-end) ! (blink-cursor-timer-function nil))) ! (defun blink-cursor-timer-function (&optional toggle) "Timer function of timer `blink-cursor-timer'." ! (if (and (not blink-cursor-saved-cursor-type) ! blink-cursor-idle-cursor-type ! (not (equal cursor-type blink-cursor-idle-cursor-type)) ! (numberp blink-cursor-idle-cursor-delay) ! (>= (float-time (or (current-idle-time) '(0 0))) ! blink-cursor-idle-cursor-delay)) ! (setq blink-cursor-saved-cursor-type cursor-type ! cursor-type blink-cursor-idle-cursor-type) ! (internal-show-cursor nil (and toggle (not (internal-show-cursor-p)))))) (defun blink-cursor-end () "Stop cursor blinking. *************** *** 1277,1282 **** --- 1301,1310 ---- When run, it cancels the timer `blink-cursor-timer' and removes itself as a pre-command hook." (remove-hook 'pre-command-hook 'blink-cursor-end) + (when blink-cursor-saved-cursor-type + (if (eq blink-cursor-idle-cursor-type cursor-type) + (setq cursor-type blink-cursor-saved-cursor-type)) + (setq blink-cursor-saved-cursor-type nil)) (internal-show-cursor nil t) (when blink-cursor-timer (cancel-timer blink-cursor-timer) -- Kim F. Storm http://www.cua.dk