diff options
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/vms-patch.el | 69 |
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 @@ | |||
| 1 | 2005-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 | |||
| 1 | 2005-03-24 Thien-Thi Nguyen <ttn@gnu.org> | 7 | 2005-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. | |||
| 193 | All other Emacs commands are still available." | 193 | All 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 | "\ | ||
| 201 | Insert a right square brace, but do other things first depending on context. | ||
| 202 | During filename completion, when point is at the end of the line and the | ||
| 203 | character before is not a right square brace, do one of three things before | ||
| 204 | inserting 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. | ||
| 208 | Additionally, if the preceding chars are right-square-brace followed by | ||
| 209 | either \"-\" 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 | "\ | ||
| 244 | Insert a colon, but do other things first depending on context. | ||
| 245 | During filename completion, when point is at the end of the line | ||
| 246 | and the line contains a right square brace, remove all characters | ||
| 247 | from the beginning of the line up to and including such brace. | ||
| 248 | This enables one to type a new filespec without having to delete | ||
| 249 | the 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 |