annotate lisp/rfn-eshadow.el @ 66175:db4304733361

(gud-menu-map): Correct condition for fringe.
author Nick Roberts <nickrob@snap.net.nz>
date Tue, 18 Oct 2005 03:44:25 +0000
parents 41bb365f41c4
children c227619d69d6 2d92f5c9d6ae
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,
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
4 ;; 2005 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
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
14 ;; any later version.
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
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63053
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63053
diff changeset
24 ;; Boston, MA 02110-1301, USA.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
25
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;;
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
28 ;; Defines the mode `file-name-shadow-mode'.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; The `read-file-name' function passes its result through
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;; `substitute-in-file-name', so any part of the string preceding
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; multiple slashes (or a drive indicator on MS-DOS/MS-Windows) is
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 ;; ignored.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;;
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
35 ;; If `file-name-shadow-mode' is active, any part of the
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; 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
37 ;; properties in `file-name-shadow-properties', which may
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
38 ;; be used to make the ignored text invisible, dim, etc.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;;; Code:
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
42
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
43
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
44 ;;; Customization
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
45
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
46 (defconst file-name-shadow-properties-custom-type
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 '(list
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 (checklist :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 (const :tag "Invisible"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 :doc "Make shadowed part of filename invisible"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 :format "%t%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
52 :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 (invisible t intangible t))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 :format "%v"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 :tag "Face"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
57 :doc "Display shadowed part of filename using a different face"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 (const :format "" face)
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
59 (face :value file-name-shadow))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
60 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
61 :format "%t: %v%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
62 :tag "Brackets"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
63 ;; Note the 4 leading spaces in the doc string;
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;; this is hack to get around the fact that the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
65 ;; newline after the second string widget comes
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 ;; from the string widget, and doesn't indent
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 ;; correctly. We could use a :size attribute to
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 ;; make the second string widget not have a
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 ;; terminating newline, but this makes it impossible
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 ;; to enter trailing whitespace, and it's desirable
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 ;; that it be possible.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
72 :doc " Surround shadowed part of filename with brackets"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 (const :format "" before-string)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 (string :format "%v" :size 4 :value "{")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 (const :format "" after-string)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
76 ;; see above about why the 2nd string doesn't use :size
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 (string :format " and: %v" :value "} "))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
78 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
79 :format "%t: %v%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 :tag "String"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
81 :doc "Display a string instead of the shadowed part of filename"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 (const :format "" display)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 (string :format "%v" :size 15 :value "<...ignored...>"))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 (const :tag "Avoid"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 :doc "Try to keep cursor out of shadowed part of filename"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
86 :format "%t%n%h"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 (field shadow)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 (repeat :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 :tag "Other Properties"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 (list :inline t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 :format "%v"
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 (symbol :tag "Property")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 (sexp :tag "Value")))))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
95
39610
630b24783d8b (read-file-name-electric-shadow-properties)
Miles Bader <miles@gnu.org>
parents: 39609
diff changeset
96 ;;;###autoload
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
97 (defcustom file-name-shadow-properties
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
98 '(face file-name-shadow field shadow)
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 "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
100 Only used when `file-name-shadow-mode' is active.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 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
102 `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
103 :type file-name-shadow-properties-custom-type
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 :group 'minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
105
39610
630b24783d8b (read-file-name-electric-shadow-properties)
Miles Bader <miles@gnu.org>
parents: 39609
diff changeset
106 ;;;###autoload
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
107 (defcustom file-name-shadow-tty-properties
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 '(before-string "{" after-string "} " field shadow)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 "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
110 Only used when `file-name-shadow-mode' is active and emacs
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 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
112 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
113 :type file-name-shadow-properties-custom-type
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
114 :group 'minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
115
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
116 (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
117 '((t :inherit shadow))
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
118 "Face used by `file-name-shadow-mode' for the shadow."
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 :group 'minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
120
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
121
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 ;;; Internal variables
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
123
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 ;; Regexp to locate dividing point between shadow and real pathname
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 (defconst rfn-eshadow-regexp
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 (cond ((memq system-type '(ms-dos windows-nt))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 ;; This horrible regexp considers the following patterns as
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 ;; starting an absolute pathname, when following a `/' or an `\':
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 ;; L: / // ~ $ \\ \\\\
39714
e6ba84d67359 (rfn-eshadow-regexp): Deal correctly with escaped dollar-signs.
Miles Bader <miles@gnu.org>
parents: 39620
diff changeset
130 "\\(.*[^/]+/+?\\|/*?\\|\\)\\(~\\|$[^$]\\|$\\'\\|[][\\^a-z]:\\|//?\\([^][\\^a-z/$~]\\|[^/$~][^:]\\|[^/$~]?\\'\\)\\)")
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 (t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 ;; default is for unix-style filenames
39714
e6ba84d67359 (rfn-eshadow-regexp): Deal correctly with escaped dollar-signs.
Miles Bader <miles@gnu.org>
parents: 39620
diff changeset
133 "\\(.*/\\)\\([/~]\\|$[^$]\\|$\\'\\)"))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 "Regular expression used to match shadowed filenames.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 There should be at least one regexp group; the end of the first one
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 is used as the end of the shadowed portion of the filename.")
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
137
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 ;; A list of minibuffers to which we've added a post-command-hook.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 (defvar rfn-eshadow-frobbed-minibufs nil)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
140
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 ;; An overlay covering the shadowed part of the filename (local to the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 ;; minibuffer).
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 (defvar rfn-eshadow-overlay)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 (make-variable-buffer-local 'rfn-eshadow-overlay)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
145
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
146
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 ;;; Hook functions
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
148
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 ;; This function goes on minibuffer-setup-hook
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 (defun rfn-eshadow-setup-minibuffer ()
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
151 "Set up a minibuffer for `file-name-shadow-mode'.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 The prompt and initial input should already have been inserted."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 (when minibuffer-completing-file-name
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 (setq rfn-eshadow-overlay
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 ;; Give rfn-eshadow-overlay the user's props.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 (let ((props
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (if window-system
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
159 file-name-shadow-properties
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
160 file-name-shadow-tty-properties)))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
161 (while props
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 (overlay-put rfn-eshadow-overlay (pop props) (pop props))))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 ;; Turn on overlay evaporation so that we don't have to worry about
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
164 ;; odd effects when the overlay sits empty at the beginning of the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 ;; minibuffer.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 (overlay-put rfn-eshadow-overlay 'evaporate t)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 ;; Add our post-command hook, and make sure can remove it later.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 (add-to-list 'rfn-eshadow-frobbed-minibufs (current-buffer))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (add-hook 'post-command-hook #'rfn-eshadow-update-overlay nil t)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
170
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 ;; post-command-hook to update overlay
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 (defun rfn-eshadow-update-overlay ()
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 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
175 `file-name-shadow-mode'; the minibuffer should have already
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 been set up by `rfn-eshadow-setup-minibuffer'."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 ;; This is not really a correct implementation; it won't always do the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 ;; right thing in the presence of environment variables that
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 ;; substitute-in-file-name would expand; currently it just assumes any
39613
32898a97e761 (rfn-eshadow-update-overlay): Use `minibuffer-prompt-end'.
Miles Bader <miles@gnu.org>
parents: 39610
diff changeset
180 ;; environment variable contains an absolute filename.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 (save-excursion
43893
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
182 (let ((inhibit-point-motion-hooks t))
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
183 (goto-char (minibuffer-prompt-end))
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
184 ;; Update the overlay (which will evaporate if it's empty).
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
185 (move-overlay rfn-eshadow-overlay
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
186 (point)
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
187 (if (looking-at rfn-eshadow-regexp)
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
188 (match-end 1)
89b76ba02505 (rfn-eshadow-update-overlay): Bind `inhibit-point-motion-hooks' to t while
Miles Bader <miles@gnu.org>
parents: 41954
diff changeset
189 (point))))))
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
190
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
191
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 ;;; Note this definition must be at the end of the file, because
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
193 ;;; `define-minor-mode' actually calls the mode-function if the
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 ;;; associated variable is non-nil, which requires that all needed
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 ;;; functions be already defined. [This is arguably a bug in d-m-m]
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 ;;;###autoload
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
197 (define-minor-mode file-name-shadow-mode
47034
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
198 "Toggle File-Name Shadow mode.
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
199 When active, any part of a filename being read in the minibuffer
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
200 that would be ignored (because the result is passed through
820cb95c5776 Doc fix.
Miles Bader <miles@gnu.org>
parents: 47028
diff changeset
201 `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
202 `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
203 that portion dim, invisible, or otherwise less visually noticeable.
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
204
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
205 With prefix argument ARG, turn on if positive, otherwise off.
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
206 Returns non-nil if the new state is enabled."
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
207 :global t
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
208 :group 'minibuffer
47028
0919c09730ad (file-name-shadow-properties-custom-type): Renamed from
Miles Bader <miles@gnu.org>
parents: 45177
diff changeset
209 (if file-name-shadow-mode
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
210 ;; Enable the mode
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
211 (add-hook 'minibuffer-setup-hook 'rfn-eshadow-setup-minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
212 ;; Disable the mode
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
213 (remove-hook 'minibuffer-setup-hook 'rfn-eshadow-setup-minibuffer)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
214 ;; 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
215 (dolist (minibuf rfn-eshadow-frobbed-minibufs)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
216 (with-current-buffer minibuf
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 (remove-hook 'post-command-hook #'rfn-eshadow-update-overlay t)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
218 (setq rfn-eshadow-frobbed-minibufs nil)))
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
219
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
220
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
221 (provide 'rfn-eshadow)
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
222
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 47075
diff changeset
223 ;;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888
39609
7e1a51c77ac6 Initial checkin.
Miles Bader <miles@gnu.org>
parents:
diff changeset
224 ;;; rfn-eshadow.el ends here