diff options
Diffstat (limited to 'basic.el')
-rw-r--r-- | basic.el | 61 |
1 files changed, 60 insertions, 1 deletions
@@ -260,7 +260,10 @@ window, then also delete the selected window." ;;; I prefer going to the top first. ;; But I don't really like always going to the top. I am still -;; thinking about solutions. +;; thinking about solutions. -- 2021-01-17 + +;; REVIEW: I am still thinking about solutions... -- 2022-01-15 +;; 00:29:48.391643 (setq recenter-positions (list 'middle 'top 'bottom)) @@ -523,3 +526,59 @@ The remaining CONFIGS are evaluated after the package is loaded." (require ,package-name) ,@configs)) +;;; Go to parent in the file name completion map + +(defun durand-delete-goto-parent-dir (n &optional kill-flag) + "Go to the parent directory when appropriate in completing file \ +names. + +This goes to the parent directory when the character before the +point is a non-escaped forward slash. + +N and KILL-FLAG have the same meaning as `delete-backward-char'." + (interactive "p\nP") + (cond + ((and + (not (use-region-p)) + ;; This variable has been said to be supposed to be obsolete + ;; since 2011, but it remains today, so I just use it here. + minibuffer-completing-file-name + (minibufferp nil t) + (member (char-before) (list ?/ ?~)) + (/= (char-before + (max (1- (point)) (minibuffer-prompt-end))) + ?\\)) + ;; HACK + (let* ((start + (let ((result (point)) + (begin (minibuffer-prompt-end)) + foundp) + (while (null foundp) + (setq foundp t) + (cond + ((or + (and + (= (char-before result) ?~) + (member (char-before (max (1- result) begin)) + (list ?/ ?~))) + (and + (= (char-before result) ?/) + (= (char-before (max (1- result) begin)) ?/))) + (setq result (max (1- result) begin))) + ((= result begin)) + ((setq result (1- result)) (setq foundp nil)))) + result)) + (file-name + (expand-file-name (buffer-substring start (point)))) + (parent + (cond + ((string= file-name "/") "") + ((file-name-directory + (directory-file-name file-name)))))) + (delete-region start (point)) + (cond + ((stringp parent) (insert (abbreviate-file-name parent)))))) + ((delete-backward-char n kill-flag)))) + +(define-key minibuffer-local-filename-completion-map + (vector ?\d) #'durand-delete-goto-parent-dir) |