From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Newsgroups: gmane.emacs.devel Subject: [PATCH] Add idle-cursor-morph. Date: Sun, 18 Oct 2015 17:19:56 +0200 Message-ID: <876124ryoz.fsf@T420.taylan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1445181607 5043 80.91.229.3 (18 Oct 2015 15:20:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Oct 2015 15:20:07 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 18 17:20:06 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 1Znpkj-0003sM-Rd for ged-emacs-devel@m.gmane.org; Sun, 18 Oct 2015 17:20:06 +0200 Original-Received: from localhost ([::1]:34271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Znpki-0001Md-TT for ged-emacs-devel@m.gmane.org; Sun, 18 Oct 2015 11:20:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Znpke-0001MR-TC for emacs-devel@gnu.org; Sun, 18 Oct 2015 11:20:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Znpkd-0007fb-Qe for emacs-devel@gnu.org; Sun, 18 Oct 2015 11:20:00 -0400 Original-Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:33574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Znpkd-0007fT-HM for emacs-devel@gnu.org; Sun, 18 Oct 2015 11:19:59 -0400 Original-Received: by wijp11 with SMTP id p11so67719997wij.0 for ; Sun, 18 Oct 2015 08:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=Rm1RyJwKp3yhsD4AgJ1wwk3PMgJ196F0ht5tt101ag4=; b=U3alQX0gHdoYiMm4unLC3v+Jt++1Ci1+4drx8UTXCYMgc9fd1uu8/hzxTyzr/FTdrC SQ35IrVimKQtGQT8BCckMvuWJNtefDbMhGUU665xNsdjZV2saNCcQvyURW+ArqaoIOFn rjbFq5DkNxAT0uxCbOzh4qPnNTa/VNjnJ1NQWV0eQh2cxeg8IrwjgkYVmUFxmD9bt/Wp thSWYi3Pu4sb58nLTQr+z25w2GFP8Xu1DJKvsk/bft4aQRQ2qyQWnEVDPrzF1sKLNCbB MF5uwsNPsRatQuziF5+PQAlxKwtNtlAmWuzFnpPuZwjcNsAy9Ba9VGvWrIMMf05DkiO/ Tt2Q== X-Received: by 10.180.72.177 with SMTP id e17mr15100734wiv.8.1445181598800; Sun, 18 Oct 2015 08:19:58 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c32:4740:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id v9sm17627359wjv.45.2015.10.18.08.19.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 08:19:57 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 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:191955 Archived-At: --=-=-= Content-Type: text/plain This is for ELPA. Admittedly this is pretty hacky, but it has worked for me since ages. 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-idle-cursor-morph.patch >From 64d1d46fd3a393cea8922661bc809012f50da301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?= Date: Sun, 18 Oct 2015 17:12:12 +0200 Subject: [PATCH] Add idle-cursor-morph. --- packages/idle-cursor-morph/idle-cursor-morph.el | 115 ++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 packages/idle-cursor-morph/idle-cursor-morph.el diff --git a/packages/idle-cursor-morph/idle-cursor-morph.el b/packages/idle-cursor-morph/idle-cursor-morph.el new file mode 100644 index 0000000..a1deb5e --- /dev/null +++ b/packages/idle-cursor-morph/idle-cursor-morph.el @@ -0,0 +1,115 @@ +;;; idle-cursor-morph.el --- Morph cursor when idle. + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Taylan Ulrich B. +;; Keywords: convenience + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Change the cursor appearance after a certain time of inactivity, so it is +;; easier to find after a pause or distraction. +;; +;; You can configure the parameters via the Customize system. + +;;; Code: + +(defgroup idle-cursor-morph nil + "Morph cursor when idle." + :group 'convenience) + +(defcustom idle-cursor-timeout 20 + "Seconds to wait before morphing the cursor. + +After setting this, run `idle-cursor-activate' to apply the new +value." + :type 'number + :group 'idle-cursor-morph) + +(defcustom idle-cursor-color "red" + "Color of cursor when idle." + :type 'string + :group 'idle-cursor-morph) + +(defcustom idle-cursor-non-idle-color "white" + "Color of cursor when not idle." + :type 'string + :group 'idle-cursor-morph) + +(defcustom idle-cursor-type 'box + "Type of cursor when idle." + :type '(choice (const t) + (const nil) + (const box) + (cons (const bar) number) + (const hbar) + (cons (const hbar) number)) + :group 'idle-cursor-morph) + +(defcustom idle-cursor-non-idle-type cursor-type + "Type of cursor when not idle." + :type '(choice (const t) + (const nil) + (const box) + (cons (const bar) number) + (const hbar) + (cons (const hbar) number)) + :group 'idle-cursor-morph) + +(defcustom idle-cursor-blinking (not no-blinking-cursor) + "Whether the cursor should blink when idle." + :type 'boolean + :group 'idle-cursor-morph) + +(defcustom idle-cursor-non-idle-blinking (not no-blinking-cursor) + "Whether the cursor should blink when not idle.") + +(defun idle-cursor-morph () + "Set the cursor color and type to `idle-cursor-color' and +`idle-cursor-type', respectively." + (set-cursor-color idle-cursor-color) + (setq-default cursor-type idle-cursor-type) + (setq no-blinking-cursor (not idle-cursor-blinking)) + (add-hook 'post-command-hook 'idle-cursor-restore)) + +(defun idle-cursor-restore () + "Restore the cursor color and type to the values they had +before `idle-cursor-morph' changed them." + (set-cursor-color idle-cursor-non-idle-color) + (setq-default cursor-type idle-cursor-non-idle-type) + (setq no-blinking-cursor (not idle-cursor-non-idle-blinking)) + (remove-hook 'post-command-hook 'idle-cursor-restore)) + +(defvar idle-cursor-morph-timer nil) + +(defun idle-cursor-activate () + "Activate the idle-cursor-morphing functionality." + (interactive) + (if idle-cursor-morph-timer + (idle-cursor-deactivate)) + (setq idle-cursor-morph-timer + (run-with-idle-timer idle-cursor-timeout t 'idle-cursor-morph))) + +(defun idle-cursor-deactivate () + "Deactivate the idle-cursor-morphing functionality." + (interactive) + (if idle-cursor-morph-timer + (cancel-timer idle-cursor-morph-timer))) + +(idle-cursor-activate) + +(provide 'idle-cursor-morph) +;;; idle-cursor-morph.el ends here -- 2.5.0 --=-=-=--