all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob a1deb5eae60cf3eb93566d1d845ffb986fb6ba87 3707 bytes (raw)
name: packages/idle-cursor-morph/idle-cursor-morph.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 
;;; idle-cursor-morph.el --- Morph cursor when idle.

;; Copyright (C) 2015  Free Software Foundation, Inc.

;; Author: Taylan Ulrich B. <taylanbayirli@gmail.com>
;; 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 <http://www.gnu.org/licenses/>.

;;; 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

debug log:

solving a1deb5e ...
found a1deb5e in https://yhetil.org/emacs/876124ryoz.fsf@T420.taylan/

applying [1/1] https://yhetil.org/emacs/876124ryoz.fsf@T420.taylan/
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

Checking patch packages/idle-cursor-morph/idle-cursor-morph.el...
Applied patch packages/idle-cursor-morph/idle-cursor-morph.el cleanly.

index at:
100644 a1deb5eae60cf3eb93566d1d845ffb986fb6ba87	packages/idle-cursor-morph/idle-cursor-morph.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.