My favorites | Sign in
dea
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
;;; dired-lis.el --- Change cursor smartly

;; Copyright (C) 2009 ahei

;; Author: ahei <ahei0802@126.com>
;; Keywords: cursor

;; This file 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, or (at your option)
;; any later version.

;; This file 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 GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:
;;
;; Change cursor smartly

;;; Installation:
;;
;; Copy cursor-change.el to your load-path and add following statement to
;; your .emacs:
;;
;; (require 'cursor-change)
;;
;; then M-x cursor-change-mode to use this library.

;;; History:
;;
;; 2009-11-22
;; * initial version 1.0.

;;; Code:

(require 'cursor-chg)

(defgroup cursor-change nil
"Group for cursor-change."
:group 'cursor
:prefix "cursor-change-")

(defvar cursor-change-old-cursor-type nil "Cursor type before toggle on function `cursor-change-mode'.")
(defvar cursor-change-old-blink-cursor-mode nil "`blink-cursor-mode' before toggle on function `crsor-change-mode'.")

(setq curchg-default-cursor-color "green")

;;;###autoload
(define-minor-mode cursor-change-mode
"Toggle `cursor-change-mode'."
:global t
:group 'cursor-change
(if cursor-change-mode
(progn
(setq cursor-change-old-cursor-type (cursor-change-get-cursor-type))
(setq cursor-change-old-blink-cursor-mode blink-cursor-mode))
(blink-cursor-mode (if cursor-change-old-blink-cursor-mode 1 -1)))
(toggle-cursor-type-when-idle cursor-change-mode)
(change-cursor-mode cursor-change-mode)
(unless cursor-change-mode
(curchg-set-cursor-type cursor-change-old-cursor-type)))

(defun cursor-change-get-cursor-type (&optional frame)
"Get cursor type of frame FRAME."
(cdr (assq 'cursor-type (frame-parameters frame))))

(defun curchg-change-cursor-on-overwrite/read-only ()
"Set cursor type differently for overwrite mode, function `view-mode', and read-only buffer.
That is, use one cursor type for overwrite mode and read-only buffers,
and another cursor type otherwise."
(curchg-set-cursor-type
(if (or buffer-read-only overwrite-mode view-mode)
curchg-overwrite/read-only-cursor-type
curchg-default-cursor-type)))

(provide 'cursor-change)

;;; cursor-change.el ends here

Change log

r647 by ahei on Nov 22, 2009   Diff
After toggle off cursor-change-mode,
restore blink-cursor-mode.
Go to: 
Project members, sign in to write a code review

Older revisions

r646 by ahei on Nov 22, 2009   Diff
Add cursor-change.
r645 by ahei on Nov 22, 2009   Diff
Add cursor-chg.
All revisions of this file

File info

Size: 2739 bytes, 85 lines

File properties

svn:mergeinfo
Powered by Google Project Hosting