From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: [PATCH] Add idle-cursor-morph. Date: Sun, 18 Oct 2015 09:00:34 -0700 (PDT) Message-ID: <1a53f340-60a0-43d4-b168-09fffcc8b187@default> References: <876124ryoz.fsf@T420.taylan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1445184068 8606 80.91.229.3 (18 Oct 2015 16:01:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Oct 2015 16:01:08 +0000 (UTC) To: taylanbayirli@gmail.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 18 18:00:52 2015 Return-path: Envelope-to: ged-emacs-devel@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 1ZnqO8-0001ky-Tr for ged-emacs-devel@m.gmane.org; Sun, 18 Oct 2015 18:00:49 +0200 Original-Received: from localhost ([::1]:34434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnqO8-0008Ni-1L for ged-emacs-devel@m.gmane.org; Sun, 18 Oct 2015 12:00:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnqO1-0008KO-4k for emacs-devel@gnu.org; Sun, 18 Oct 2015 12:00:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnqNx-0001jB-0K for emacs-devel@gnu.org; Sun, 18 Oct 2015 12:00:41 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:23396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnqNw-0001iz-Q1 for emacs-devel@gnu.org; Sun, 18 Oct 2015 12:00:36 -0400 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t9IG0ZwB009788 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 18 Oct 2015 16:00:35 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t9IG0YLH001302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 18 Oct 2015 16:00:35 GMT Original-Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t9IG0YJw002761; Sun, 18 Oct 2015 16:00:34 GMT In-Reply-To: <876124ryoz.fsf@T420.taylan> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:191961 Archived-At: > This is for ELPA. >=20 > Admittedly this is pretty hacky, but it has worked for me since ages. >=20 > It also has a bug I have no idea how to chase: every once in a blue moon > it will fail to restore the cursor color. I'm guessing it's probably a > bug in Emacs since the implementation is so simple and restoring the > style works, but don't know really. FWIW, this has been in my code (in `oneonone.el') since 2006. (I haven't come across that blue-moon problem, BTW.) --- (defun 1on1-toggle-box-cursor-when-idle (&optional arg) "Turn on or off automatically changing to a box cursor when idle. When on, the cursor is changed to a box whenever Emacs is idle. With prefix argument, turn on if ARG > 0; else turn off." (interactive "P") (setq 1on1-box-cursor-when-idle-p (if arg (> (prefix-numeric-value arg) 0) (not 1on1-box-cursor-when-idle-p))) (cond (1on1-box-cursor-when-idle-p (timer-activate-when-idle 1on1-box-cursor-when-idle-timer) (add-hook 'pre-command-hook '1on1-box-cursor-when-idle-off) (message "Turned ON making cursor a box when Emacs is idle.")) (t (cancel-timer 1on1-box-cursor-when-idle-timer) (remove-hook 'pre-command-hook '1on1-box-cursor-when-idle-off) (message "Turned OFF making cursor a box when Emacs is idle.")))) (defun 1on1-set-cursor-type (cursor-type) "Set the cursor type of the selected frame to CURSOR-TYPE. When called interactively, prompt for the type to use. To get the frame's current cursor type, use `frame-parameters'." (interactive (list (intern (completing-read "Cursor type: " (mapcar 'list '("box" "hollow" "bar" "hbar" nil)))))) (modify-frame-parameters (selected-frame) (list (cons 'cursor-type cursor-type)))) (defun 1on1-box-cursor-when-idle () "Change the cursor to a box cursor when Emacs is idle." (let ((type (cdr (assoc 'cursor-type (frame-parameters))))) (unless (eq type 'box) (setq 1on1-last-cursor-type type) (1on1-set-cursor-type 'box)))) (defun 1on1-box-cursor-when-idle-off () "Turn off changing the cursor to a box cursor when Emacs is idle." (when 1on1-last-cursor-type (1on1-set-cursor-type 1on1-last-cursor-type))) (defvar 1on1-box-cursor-when-idle-p t "Non-nil means to use a box cursor whenever Emacs is idle. Do NOT change this yourself; instead, use \ `\\[1on1-toggle-box-cursor-when-idle]'.") (defvar 1on1-box-cursor-when-idle-interval 2 "Number of seconds to wait before changing cursor type to box. Do NOT change this yourself to change the wait period; instead, use `\\[1on1-set-box-cursor-when-idle-interval]'.") (defvar 1on1-box-cursor-when-idle-timer (progn=20 (when (boundp '1on1-box-cursor-when-idle-timer) (cancel-timer 1on1-box-cursor-when-idle-timer)) (run-with-idle-timer 1on1-box-cursor-when-idle-interval t '1on1-box-cursor-when-idle)) "Timer used to change the cursor to a box cursor when Emacs is idle.") (cancel-timer 1on1-box-cursor-when-idle-timer)