├── .gitignore ├── Cask ├── README.org ├── smart-cursor-color.el ├── smart-cursor-color.melpa └── todo.org /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Emacs ### 4 | # -*- mode: gitignore; -*- 5 | *~ 6 | \#*\# 7 | /.emacs.desktop 8 | /.emacs.desktop.lock 9 | *.elc 10 | auto-save-list 11 | tramp 12 | .\#* 13 | 14 | # Org-mode 15 | .org-id-locations 16 | *_archive 17 | 18 | # flymake-mode 19 | *_flymake.* 20 | 21 | # eshell files 22 | /eshell/history 23 | /eshell/lastdir 24 | 25 | # elpa packages 26 | /elpa/ 27 | 28 | # reftex files 29 | *.rel 30 | 31 | # AUCTeX auto folder 32 | /auto/ 33 | 34 | # cask packages 35 | .cask/ 36 | 37 | -------------------------------------------------------------------------------- /Cask: -------------------------------------------------------------------------------- 1 | (source melpa) 2 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | [[http://melpa.org/#/smart-cursor-color][file:http://melpa.org/packages/smart-cursor-color-badge.svg]] 2 | * smart-cursor-color-mode 3 | Change cursor-color dynamically on Emacs. 4 | [[http://www.iterm2.com/#/section/home][iTerm2]] have `smart cursor color'. 5 | But GNU Emacs doesn't have this option. 6 | The `smart-cursor-color-mode' can make do that. 7 | 8 | ** Quickstart 9 | To make the mode enabled every time Emacs starts, add the following 10 | to Emacs initialisation file (~/.emacs or ~/.emacs.d/init.el): 11 | 12 | - If installed from [[https://melpa.org/#/][MELPA]] 13 | 14 | #+BEGIN_SRC emacs-lisp 15 | (smart-cursor-color-mode +1) 16 | #+END_SRC 17 | 18 | - If installed manually, 19 | #+BEGIN_SRC emacs-lisp 20 | (add-to-list 'load-path "path-to-installed-directory") 21 | (require 'smart-cursor-color) 22 | (smart-cursor-color-mode +1) 23 | #+END_SRC 24 | 25 | When hl-line-mode is on, 26 | smart-cursor-color-mode is not work. 27 | So must turn off hl-line-mode. 28 | 29 | #+BEGIN_SRC emacs-lisp 30 | (hl-line-mode -1) 31 | #+END_SRC 32 | 33 | But when global-hl-line-mode is on, 34 | smart-cursor-color-mode is work. 35 | #+BEGIN_SRC emacs-lisp 36 | (global-hl-line-mode +1) 37 | (smart-cursor-color-mode +1) 38 | #+END_SRC 39 | 40 | -------------------------------------------------------------------------------- /smart-cursor-color.el: -------------------------------------------------------------------------------- 1 | ;;; smart-cursor-color.el --- Change cursor color dynamically 2 | ;; 3 | ;; Filename: smart-cursor-color.el 4 | ;; Description: Change cursor color dynamically at cursor or pointer. 5 | ;; Author: 7696122 6 | ;; Maintainer: 7696122 7 | ;; Created: Thu Oct 31 21:33:34 2013 (+0900) 8 | ;; Version: 0.0.6 9 | ;; Package-Requires: () 10 | ;; Last-Updated: Tue Apr 29 22:35:48 2014 (+0900) 11 | ;; By: 7696122 12 | ;; Update #: 403 13 | ;; URL: https://github.com/7696122/smart-cursor-color/ 14 | ;; Doc URL: http://7696122.github.io/smart-cursor-color/ 15 | ;; Keywords: cursor, color, face 16 | ;; Compatibility: GNU Emacs: 24.x 17 | ;; 18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 19 | ;; 20 | ;;; Commentary: 21 | ;; 22 | ;; Quickstart 23 | ;; 24 | ;; To make the mode enabled every time Emacs starts, add the following 25 | ;; to Emacs initialisation file (~/.emacs or ~/.emacs.d/init.el): 26 | ;; 27 | ;; If installed from melpa. 28 | ;; (smart-cursor-color-mode 1) 29 | ;; 30 | ;; If installed manually, 31 | ;; (add-to-list 'load-path "path-to-installed-directory") 32 | ;; (require 'smart-cursor-color) 33 | ;; (smart-cursor-color-mode 1) 34 | ;; 35 | ;; When hl-line-mode is on, 36 | ;; smart-cursor-color-mode is not work. 37 | ;; So must turn off hl-line-mode. 38 | ;; (hl-line-mode -1) 39 | ;; 40 | ;; But when global-hl-line-mode is on, 41 | ;; smart-cursor-color-mode is work. 42 | ;; (global-hl-line-mode 1) 43 | ;; (smart-cursor-color-mode 1) 44 | ;; 45 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 46 | ;; 47 | ;;; Change Log: 48 | ;; 49 | ;; 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 51 | ;; 52 | ;; This program is free software; you can redistribute it and/or 53 | ;; modify it under the terms of the GNU General Public License as 54 | ;; published by the Free Software Foundation; either version 3, or 55 | ;; (at your option) any later version. 56 | ;; 57 | ;; This program is distributed in the hope that it will be useful, 58 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 59 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 60 | ;; General Public License for more details. 61 | ;; 62 | ;; You should have received a copy of the GNU General Public License 63 | ;; along with this program; see the file COPYING. If not, write to 64 | ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth 65 | ;; Floor, Boston, MA 02110-1301, USA. 66 | ;; 67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 68 | ;; 69 | ;;; Code: 70 | 71 | (defvar scc--last-cursor-color nil 72 | "Current cursor color for smart-cursor-color-mode.") 73 | 74 | (defvar scc--default-cursor-color nil 75 | "Default cursor color. When picked foreground color is nil, use this.") 76 | 77 | (defvar scc--saved-cursor-color nil 78 | "Saved cursor color. When turn off smart-cursor-color-mode, restore origin cursor color.") 79 | 80 | (defgroup smart-cursor-color nil 81 | "" 82 | :group 'cursor) 83 | 84 | (defcustom scc--ignore-modes '(org-agenda-mode) 85 | "" 86 | :group 'smart-cursor-color) 87 | 88 | (defun scc--set-cursor-color () 89 | "Change cursor color dynamically." 90 | (unless (member major-mode scc--ignore-modes) 91 | (let ((picked-color (foreground-color-at-point))) 92 | (if picked-color 93 | (unless (eq picked-color scc--last-cursor-color) 94 | (setq scc--last-cursor-color picked-color) 95 | (set-cursor-color scc--last-cursor-color)) 96 | (unless (eq scc--default-cursor-color scc--last-cursor-color) 97 | (setq scc--last-cursor-color scc--default-cursor-color) 98 | (set-cursor-color scc--default-cursor-color)))))) 99 | 100 | (defun scc--fix-global-hl-line-mode () 101 | "for global-hl-line-mode." 102 | (if (and global-hl-line-mode 103 | smart-cursor-color-mode) 104 | (progn 105 | (smart-cursor-color-mode -1) 106 | (smart-cursor-color-mode +1)))) 107 | 108 | ;; (defun scc--reset-cursor-color () 109 | ;; "" 110 | ;; (set-cursor-color scc--default-cursor-color)) 111 | 112 | (add-hook 'global-hl-line-mode-hook 'scc--fix-global-hl-line-mode) 113 | 114 | ;;;###autoload 115 | (define-minor-mode smart-cursor-color-mode 116 | "Dynamically changed cursor color at point's color." 117 | :lighter " scc" :global t :group 'smart-cursor-color :require 'smart-cursor-color 118 | (if smart-cursor-color-mode 119 | (progn 120 | (setq scc--default-cursor-color (frame-parameter nil 'foreground-color)) 121 | (setq scc--saved-cursor-color (frame-parameter nil 'cursor-color)) 122 | (add-hook 'post-command-hook 'scc--set-cursor-color) 123 | ;; (add-hook 'buffer-list-update-hook 'scc--reset-cursor-color) 124 | ) 125 | (remove-hook 'post-command-hook 'scc--set-cursor-color) 126 | ;; (remove-hook 'buffer-list-update-hook 'scc--reset-cursor-color) 127 | (unless (equal (frame-parameter nil 'cursor-color) scc--saved-cursor-color) 128 | (set-cursor-color scc--saved-cursor-color)))) 129 | 130 | ;;;###autoload 131 | (defun turn-on-smart-cursor-color () 132 | "Unconditionally turn on `smart-cursor-color-mode'." 133 | (interactive) 134 | (smart-cursor-color-mode +1)) 135 | 136 | ;;;###autoload 137 | (defun turn-off-smart-cursor-color () 138 | "Unconditionally turn off `smart-cursor-color-mode'." 139 | (interactive) 140 | (smart-cursor-color-mode -1)) 141 | 142 | (provide 'smart-cursor-color) 143 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 144 | ;;; smart-cursor-color.el ends here 145 | -------------------------------------------------------------------------------- /smart-cursor-color.melpa: -------------------------------------------------------------------------------- 1 | (smart-cursor-color :fetcher github :repo "7696122/smart-cursor-color") 2 | -------------------------------------------------------------------------------- /todo.org: -------------------------------------------------------------------------------- 1 | * Todos [0/2] 2 | - [ ] Fix stopped moving cursor problem when run command next-line. 3 | - [ ] Make eanble when highlight line mode is on. 4 | --------------------------------------------------------------------------------