annotate lisp/gutter.el @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents
children 501cfd01ee6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
1 ;;; gutter.el --- Gutter manipulation for XEmacs.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
2
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
4 ;; Copyright (C) 1999, 2000 Andy Piper.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
5
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
7 ;; Keywords: frames, extensions, internal, dumped
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
8
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
10
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
14 ;; any later version.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
15
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
19 ;; General Public License for more details.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
20
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
22 ;; along with Xmacs; see the file COPYING. If not, write to the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
25
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
26 ;; Some of this is taken from the buffer-menu stuff in menubar-items.el
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
27 ;; and the custom specs in toolbar.el.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
28
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
29 (defgroup gutter nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
30 "Input from the gutters."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
31 :group 'environment)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
32
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
33 ;; Although these customizations appear bogus, they are neccessary in
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
34 ;; order to be able to save options through the options menu.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
35 (defcustom default-gutter-position
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
36 (default-gutter-position)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
37 "The location of the default gutter. It can be 'top, 'bottom, 'left or
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
38 'right. This option should be customized through the options menu.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
39 To set the gutter position explicitly use `set-default-gutter-position'"
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
40 :group 'gutter
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
41 :type '(choice (const :tag "top" top)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
42 (const :tag "bottom" bottom)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
43 (const :tag "left" left)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
44 (const :tag "right" right))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
45 :set #'(lambda (var val)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
46 (set-default-gutter-position val)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
47 (setq default-gutter-position val)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
48
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
49 ;;; Gutter helper functions
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
50
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
51 ;; called by Fset_default_gutter_position()
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
52 (defvar default-gutter-position-changed-hook nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
53 "Function or functions to be called when the gutter position is changed.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
54 The value of this variable may be buffer-local.")
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
55
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
56 ;; called by set-gutter-element-visible-p
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
57 (defvar gutter-element-visibility-changed-hook nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
58 "Function or functions to be called when the visibility of an
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
59 element in the gutter changes. The value of this variable may be
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
60 buffer-local. The gutter element symbol is passed as an argument to
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
61 the hook, as is the visibility flag.")
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
62
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
63 (defun set-gutter-element (gutter-specifier prop val &optional locale tag-set)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
64 "Set GUTTER-SPECIFIER gutter element PROP to VAL in optional LOCALE.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
65 This is a convenience function for setting gutter elements.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
66 VAL in general must be a string. If VAL is a glyph then a string will be
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
67 created to put the glyph into."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
68 (let ((spec val))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
69 (when (glyphp val)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
70 (setq spec (copy-sequence "\n"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
71 (set-extent-begin-glyph (make-extent 0 1 spec) val))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
72 (map-extents #'(lambda (extent arg)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
73 (set-extent-property extent 'duplicable t)) spec)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
74 (modify-specifier-instances gutter-specifier #'plist-put (list prop spec)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
75 'force nil locale tag-set)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
76
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
77 (defun remove-gutter-element (gutter-specifier prop &optional locale tag-set)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
78 "Remove gutter element PROP from GUTTER-SPECIFIER in optional LOCALE.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
79 This is a convenience function for removing gutter elements."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
80 (modify-specifier-instances gutter-specifier #'plist-remprop (list prop)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
81 'force nil locale tag-set))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
82
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
83 (defun set-gutter-element-visible-p (gutter-visible-specifier-p
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
84 prop &optional visible-p
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
85 locale tag-set)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
86 "Change the visibility of gutter elements.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
87 Set the visibility of element PROP to VISIBLE-P for
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
88 GUTTER-SPECIFIER-VISIBLE-P in optional LOCALE.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
89 This is a convenience function for hiding and showing gutter elements."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
90 (modify-specifier-instances
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
91 gutter-visible-specifier-p #'(lambda (spec prop visible-p)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
92 (if (consp spec)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
93 (if visible-p
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
94 (if (memq prop spec) spec
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
95 (cons prop spec))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
96 (delq prop spec))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
97 (if visible-p (list prop))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
98 (list prop visible-p)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
99 'force nil locale tag-set)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
100 (run-hook-with-args 'gutter-element-visibility-changed-hook prop visible-p))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
101
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
102 (defun gutter-element-visible-p (gutter-visible-specifier-p
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
103 prop &optional domain)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
104 "Determine whether a gutter element is visible.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
105 Given GUTTER-VISIBLE-SPECIFIER-P and gutter element PROP, return
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
106 non-nil if it is visible in optional DOMAIN."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
107 (let ((spec (specifier-instance gutter-visible-specifier-p domain)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
108 (or (and (listp spec) (memq 'buffers-tab spec))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
109 spec)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
110
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
111 (defun init-gutter ()
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
112 "Initialize the gutter."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
113 ;; do nothing as yet.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
114 )
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
115
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
116 ;;; gutter.el ends here.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
117
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents:
diff changeset
118