annotate lisp/rfn-eshadow.el @ 106802:b92c3979701c

Replace emacs-pretest-bug with bug-gnu-emacs mailing list. See http://lists.gnu.org/archive/html/emacs-devel/2009-12/msg00758.html * emacs.c (REPORT_EMACS_BUG_PRETEST_ADDRESS): Set it to bug-gnu-emacs rather than emacs-pretest-bug. * mail/emacsbug.el (report-emacs-bug-pretest-address): Set it to bug-gnu-emacs rather than emacs-pretest-bug. * CONTRIBUTE, NEWS: Use bug-gnu-emacs rather than emacs-pretest-bug for bug reports for development versions. * trouble.texi (Checklist): Use bug-gnu-emacs rather than emacs-pretest-bug for bug reports for development versions. * emacs-pretesters, make-announcement: Use bug-gnu-emacs rather than emacs-pretest-bug for bug reports for development versions. * INSTALL.BZR, README: Use bug-gnu-emacs rather than emacs-pretest-bug for bug reports for development versions.
author Glenn Morris <rgm@gnu.org>
date Mon, 11 Jan 2010 21:11:05 -0800
parents 26baacb565b0
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; rfn-eshadow.el --- Highlight `shadowed' part of read-file-name input text
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
2 ;;
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Author: Miles Bader <miles@gnu.org>
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
7 ;; Keywords: convenience minibuffer
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
8
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
14 ;; (at your option) any later version.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
15
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
20
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
23
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
25 ;;
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
26 ;; Defines the mode `file-name-shadow-mode'.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; The `read-file-name' function passes its result through
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;; `substitute-in-file-name', so any part of the string preceding
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; multiple slashes (or a drive indicator on MS-DOS/MS-Windows) is
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;; ignored.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;;
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
33 ;; If `file-name-shadow-mode' is active, any part of the
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;; minibuffer text that would be ignored because of this is given the
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
35 ;; properties in `file-name-shadow-properties', which may
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; be used to make the ignored text invisible, dim, etc.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
37 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
38
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;;; Code:
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
41
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
42 ;;; Customization
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
43
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
44 (defconst file-name-shadow-properties-custom-type
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 '(list
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
46 (checklist :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 (const :tag "Invisible"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 :doc "Make shadowed part of filename invisible"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 :format "%t%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 (invisible t intangible t))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
52 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 :format "%v"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 :tag "Face"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 :doc "Display shadowed part of filename using a different face"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 (const :format "" face)
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
57 (face :value file-name-shadow))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
59 :format "%t: %v%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
60 :tag "Brackets"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
61 ;; Note the 4 leading spaces in the doc string;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
62 ;; this is hack to get around the fact that the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
63 ;; newline after the second string widget comes
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;; from the string widget, and doesn't indent
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 ;; correctly. We could use a :size attribute to
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 ;; make the second string widget not have a
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 ;; terminating newline, but this makes it impossible
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 ;; to enter trailing whitespace, and it's desirable
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 ;; that it be possible.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 :doc " Surround shadowed part of filename with brackets"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 (const :format "" before-string)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
72 (string :format "%v" :size 4 :value "{")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 (const :format "" after-string)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 ;; see above about why the 2nd string doesn't use :size
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 (string :format " and: %v" :value "} "))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 :format "%t: %v%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
78 :tag "String"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
79 :doc "Display a string instead of the shadowed part of filename"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 (const :format "" display)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
81 (string :format "%v" :size 15 :value "<...ignored...>"))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 (const :tag "Avoid"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 :doc "Try to keep cursor out of shadowed part of filename"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 :format "%t%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 (field shadow)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 (repeat :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 :tag "Other Properties"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 :format "%v"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 (symbol :tag "Property")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 (sexp :tag "Value")))))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
93
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
94 (defcustom file-name-shadow-properties
105870
26baacb565b0 * textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 104990
diff changeset
95 ;; FIXME: should we purecopy this?
26baacb565b0 * textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 104990
diff changeset
96 '(face file-name-shadow field shadow)
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 "Properties given to the `shadowed' part of a filename in the minibuffer.
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
98 Only used when `file-name-shadow-mode' is active.
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
99 If Emacs is not running under a window system,
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
100 `file-name-shadow-tty-properties' is used instead."
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
101 :type file-name-shadow-properties-custom-type
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
102 :group 'minibuffer
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
103 :version "22.1")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
104
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
105 (defcustom file-name-shadow-tty-properties
105870
26baacb565b0 * textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 104990
diff changeset
106 (purecopy '(before-string "{" after-string "} " field shadow))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 "Properties given to the `shadowed' part of a filename in the minibuffer.
73750
a8f0f78b5599 (file-name-shadow-tty-properties): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
108 Only used when `file-name-shadow-mode' is active and Emacs
a8f0f78b5599 (file-name-shadow-tty-properties): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
109 is not running under a window-system; if Emacs is running under a window
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
110 system, `file-name-shadow-properties' is used instead."
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
111 :type file-name-shadow-properties-custom-type
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
112 :group 'minibuffer
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
113 :version "22.1")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
114
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
115 (defface file-name-shadow
63053
4ef6975cd244 * rfn-eshadow.el (file-name-shadow): Inherit from `shadow' face.
Juri Linkov <juri@jurta.org>
parents: 52401
diff changeset
116 '((t :inherit shadow))
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
117 "Face used by `file-name-shadow-mode' for the shadow."
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
118 :group 'minibuffer
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
119 :version "22.1")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
120
84739
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
121 (defvar rfn-eshadow-setup-minibuffer-hook nil
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
122 "Minibuffer setup functions from other packages.")
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
123
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
124 (defvar rfn-eshadow-update-overlay-hook nil
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
125 "Customer overlay functions from other packages")
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
126
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
127
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 ;;; Internal variables
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
129
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 ;; A list of minibuffers to which we've added a post-command-hook.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 (defvar rfn-eshadow-frobbed-minibufs nil)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
132
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 ;; An overlay covering the shadowed part of the filename (local to the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 ;; minibuffer).
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 (defvar rfn-eshadow-overlay)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 (make-variable-buffer-local 'rfn-eshadow-overlay)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
137
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
138
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 ;;; Hook functions
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
140
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 ;; This function goes on minibuffer-setup-hook
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 (defun rfn-eshadow-setup-minibuffer ()
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
143 "Set up a minibuffer for `file-name-shadow-mode'.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 The prompt and initial input should already have been inserted."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 (when minibuffer-completing-file-name
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 (setq rfn-eshadow-overlay
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 ;; Give rfn-eshadow-overlay the user's props.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 (let ((props
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 (if window-system
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
151 file-name-shadow-properties
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
152 file-name-shadow-tty-properties)))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 (while props
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 (overlay-put rfn-eshadow-overlay (pop props) (pop props))))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 ;; Turn on overlay evaporation so that we don't have to worry about
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 ;; odd effects when the overlay sits empty at the beginning of the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 ;; minibuffer.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (overlay-put rfn-eshadow-overlay 'evaporate t)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 ;; Add our post-command hook, and make sure can remove it later.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer))
84739
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
161 (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t)
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
162 ;; Run custom hook
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
163 (run-hooks 'rfn-eshadow-setup-minibuffer-hook)))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
164
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
165 (defsubst rfn-eshadow-sifn-equal (goal pos)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
166 (equal goal (condition-case nil
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
167 (substitute-in-file-name
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
168 (buffer-substring-no-properties pos (point-max)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
169 ;; `substitute-in-file-name' can fail on partial input.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
170 (error nil))))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
171
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 ;; post-command-hook to update overlay
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 (defun rfn-eshadow-update-overlay ()
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input.
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
175 This is intended to be used as a minibuffer `post-command-hook' for
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
176 `file-name-shadow-mode'; the minibuffer should have already
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 been set up by `rfn-eshadow-setup-minibuffer'."
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
178 (condition-case nil
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
179 (let ((goal (substitute-in-file-name (minibuffer-contents)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
180 (mid (overlay-end rfn-eshadow-overlay))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
181 (start (minibuffer-prompt-end))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
182 (end (point-max)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
183 (unless
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
184 ;; Catch the common case where the shadow does not need to move.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
185 (and mid
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
186 (or (eq mid end)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
187 (not (rfn-eshadow-sifn-equal goal (1+ mid))))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
188 (or (eq mid start)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
189 (rfn-eshadow-sifn-equal goal mid)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
190 ;; Binary search for the greatest position still equivalent to
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
191 ;; the whole.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
192 (while (or (< (1+ start) end)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
193 (if (and (< (1+ end) (point-max))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
194 (rfn-eshadow-sifn-equal goal (1+ end)))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
195 ;; (SIFN end) != goal, but (SIFN (1+end)) == goal,
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
196 ;; We've reached a discontinuity: this can happen
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
197 ;; e.g. if `end' point to "/:...".
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
198 (setq start (1+ end) end (point-max))))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
199 (setq mid (/ (+ start end) 2))
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
200 (if (rfn-eshadow-sifn-equal goal mid)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
201 (setq start mid)
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
202 (setq end mid)))
84739
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
203 (move-overlay rfn-eshadow-overlay (minibuffer-prompt-end) start))
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
204 ;; Run custom hook
ed643c57fe39 * rfn-eshadow.el (rfn-eshadow-setup-minibuffer-hook)
Michael Albinus <michael.albinus@gmx.de>
parents: 78236
diff changeset
205 (run-hooks 'rfn-eshadow-update-overlay-hook))
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
206 ;; `substitute-in-file-name' can fail on partial input.
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
207 (error nil)))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
208
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
209 (define-minor-mode file-name-shadow-mode
47034
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
210 "Toggle File-Name Shadow mode.
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
211 When active, any part of a filename being read in the minibuffer
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
212 that would be ignored (because the result is passed through
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
213 `substitute-in-file-name') is given the properties in
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
214 `file-name-shadow-properties', which can be used to make
45177
3cb6d6563fba rfn-eshadow.el (read-file-name-electric-shadow-mode): Fix typos in
Juanma Barranquero <lekktu@gmail.com>
parents: 43893
diff changeset
215 that portion dim, invisible, or otherwise less visually noticeable.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
216
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 With prefix argument ARG, turn on if positive, otherwise off.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
218 Returns non-nil if the new state is enabled."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
219 :global t
104990
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
220 ;; We'd like to use custom-initialize-set here so the setup is done
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
221 ;; before dumping, but at the point where the defcustom is evaluated,
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
222 ;; the corresponding function isn't defined yet, so
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
223 ;; custom-initialize-set signals an error.
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
224 :initialize 'custom-initialize-delay
66905
e0955732eb23 (file-name-shadow-mode): Set :init-value to t.
Luc Teirlinck <teirllm@auburn.edu>
parents: 66900
diff changeset
225 :init-value t
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
226 :group 'minibuffer
66918
a4fc9278ae05 (file-name-shadow-properties, file-name-shadow-tty-properties)
Luc Teirlinck <teirllm@auburn.edu>
parents: 66911
diff changeset
227 :version "22.1"
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
228 (if file-name-shadow-mode
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
229 ;; Enable the mode
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
230 (add-hook 'minibuffer-setup-hook 'rfn-eshadow-setup-minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
231 ;; Disable the mode
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
232 (remove-hook 'minibuffer-setup-hook 'rfn-eshadow-setup-minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
233 ;; Remove our entry from any post-command-hook variable's it's still in
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
234 (dolist (minibuf rfn-eshadow-frobbed-minibufs)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
235 (with-current-buffer minibuf
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
236 (remove-hook 'post-command-hook #'rfn-eshadow-update-overlay t)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
237 (setq rfn-eshadow-frobbed-minibufs nil)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
238
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
239
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
240 (provide 'rfn-eshadow)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
241
66900
c227619d69d6 (rfn-eshadow-regexp): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
242 ;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
243 ;;; rfn-eshadow.el ends here