aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2005-05-25 15:24:35 +0000
committerThien-Thi Nguyen2005-05-25 15:24:35 +0000
commit631e464e000997793d766a9eb3e5a49d16b2a7c8 (patch)
treebd638a52d6a7191ee868f2a321d477eba942fa4a
parentdcb361bef874047f18e230f8f48e14ac1091cd92 (diff)
downloademacs-631e464e000997793d766a9eb3e5a49d16b2a7c8.tar.gz
emacs-631e464e000997793d766a9eb3e5a49d16b2a7c8.zip
(vms-magic-right-square-brace, vms-magic-colon): New funcs.other-branches/ttn-vms-21-2-stash
In minibuffer-local-completion-map bind `]', `/' and `:' to them.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/vms-patch.el69
2 files changed, 74 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7ae544ea1fc..69458392127 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12005-05-25 Thien-Thi Nguyen <ttn@gnu.org>
2
3 * vms-patch.el (vms-magic-right-square-brace, vms-magic-colon):
4 New funcs. In minibuffer-local-completion-map bind `]', `/'
5 and `:' to them.
6
12005-03-24 Thien-Thi Nguyen <ttn@gnu.org> 72005-03-24 Thien-Thi Nguyen <ttn@gnu.org>
2 8
3 * progmodes/dcl-mode.el (dcl-imenu-generic-expression): 9 * progmodes/dcl-mode.el (dcl-imenu-generic-expression):
diff --git a/lisp/vms-patch.el b/lisp/vms-patch.el
index 3d8a9c59647..98f33c2bf6d 100644
--- a/lisp/vms-patch.el
+++ b/lisp/vms-patch.el
@@ -147,7 +147,7 @@ spawned Emacs and doing things like \"emacs -l myfile.el -f doit\""
147 (< 32 (setq this-char (aref args end))) 147 (< 32 (setq this-char (aref args end)))
148 (> 127 this-char)) 148 (> 127 this-char))
149 (setq end (1+ end))) 149 (setq end (1+ end)))
150 (setq command-line-args (append 150 (setq command-line-args (append
151 command-line-args 151 command-line-args
152 (list (substring args beg end)))) 152 (list (substring args beg end))))
153 (setq beg (1+ end))) 153 (setq beg (1+ end)))
@@ -193,4 +193,71 @@ following bindings are established.
193All other Emacs commands are still available." 193All other Emacs commands are still available."
194 t) 194 t)
195 195
196;;;
197;;; Filename handling in the minibuffer
198;;;
199(defun vms-magic-right-square-brace ()
200 "\
201Insert a right square brace, but do other things first depending on context.
202During filename completion, when point is at the end of the line and the
203character before is not a right square brace, do one of three things before
204inserting the brace:
205 - If there are already two left square braces preceding, do nothing special.
206 - If there is a previous right-square-brace, convert it to dot.
207 - If the character before is dot, delete it.
208Additionally, if the preceding chars are right-square-brace followed by
209either \"-\" or \"..\", strip one level of directory hierarchy."
210 (interactive)
211 (when (and minibuffer-completing-file-name
212 (= (point) (point-max))
213 (not (= 93 (char-before))))
214 (cond
215 ;; Avoid clobbering: user:[one.path][another.path
216 ((search-backward "[" (field-beginning) t 2))
217 ((search-backward "]" (field-beginning) t)
218 (delete-char 1)
219 (insert ".")
220 (goto-char (point-max)))
221 ((= ?. (char-before))
222 (delete-char -1)))
223 (goto-char (point-max))
224 (let ((specs '(".." "-"))
225 (pmax (point-max)))
226 (while specs
227 (let* ((up (car specs))
228 (len (length up))
229 (cut (- (point) len)))
230 (when (and (< (1+ len) pmax)
231 (= ?. (char-before cut))
232 (string= up (buffer-substring cut (point))))
233 (delete-char (- (1+ len)))
234 (while (not (let ((c (char-before)))
235 (or (= ?. c) (= 91 c))))
236 (delete-char -1))
237 (when (= ?. (char-before)) (delete-char -1))
238 (setq specs nil)))
239 (setq specs (cdr specs)))))
240 (insert "]"))
241
242(defun vms-magic-colon ()
243 "\
244Insert a colon, but do other things first depending on context.
245During filename completion, when point is at the end of the line
246and the line contains a right square brace, remove all characters
247from the beginning of the line up to and including such brace.
248This enables one to type a new filespec without having to delete
249the old one."
250 (interactive)
251 (when (and minibuffer-completing-file-name
252 (= (point) (point-max))
253 (search-backward "]" (field-beginning) t))
254 (delete-region (field-beginning) (1+ (point)))
255 (goto-char (point-max)))
256 (insert ":"))
257
258(let ((m minibuffer-local-completion-map))
259 (define-key m "]" 'vms-magic-right-square-brace)
260 (define-key m "/" 'vms-magic-right-square-brace)
261 (define-key m ":" 'vms-magic-colon))
262
196;;; vms-patch.el ends here 263;;; vms-patch.el ends here