summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-01-15 03:24:11 +0800
committerJSDurand <mmemmew@gmail.com>2022-01-15 03:27:38 +0800
commita51356739139777809c4d79e24356aa97f63db49 (patch)
tree82e3344cac033d2c27d1527a17be263ea0a92ee7
parent249de03acdc876eade36b873766dc176584dbab3 (diff)
clean up things & go to parent in file name completion
* basic.el (durand-delete-goto-parent-dir) (minibuffer-local-filename-completion-map): The DEL key goes to the parent directory when the cursor is before a forward slash representing a directory name. This is bound in the keymap that is only used when completing file names. * flymake-conf.el (flymake-mode-map): Bind keys to the s-m prefix. Also clean up the file. * init.el (eshell): Start tracking time immediately. (global-map, prepare-flymake): Prepare loading flymake by a keybinding.
-rw-r--r--basic.el61
-rw-r--r--flymake-conf.el38
-rw-r--r--init.el5
3 files changed, 101 insertions, 3 deletions
diff --git a/basic.el b/basic.el
index beb08dc..425edae 100644
--- a/basic.el
+++ b/basic.el
@@ -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)
diff --git a/flymake-conf.el b/flymake-conf.el
index 651aa81..28f8c4e 100644
--- a/flymake-conf.el
+++ b/flymake-conf.el
@@ -1,3 +1,29 @@
+;;; flymake-conf.el --- My configurations for Flymake -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 李俊緯
+
+;; Author: 李俊緯 <durand@jsdurand.xyz>
+;; Keywords: convenience, help, maint, tools
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Configure Flymake to my liking.
+
+;;; Code:
+
(require 'flymake)
(setq flymake-fringe-indicator-position 'left-fringe)
@@ -9,6 +35,16 @@
(setq flymake-wrap-around t)
(define-key flymake-mode-map (vector ?\C-c ?! ?s) #'flymake-start)
-(define-key flymake-mode-map (vector ?\C-c ?! ?d) #'flymake-show-diagnostics-buffer)
+(define-key flymake-mode-map (vector ?\C-c ?! ?d) #'flymake-show-buffer-diagnostics)
(define-key flymake-mode-map (vector ?\C-c ?! ?n) #'flymake-goto-next-error)
(define-key flymake-mode-map (vector ?\C-c ?! ?p) #'flymake-goto-prev-error)
+
+(define-key global-map (vector ?\s-m) nil)
+(define-key global-map (vector ?\s-m ?s) #'flymake-start)
+(define-key global-map (vector ?\s-m ?m) #'flymake-mode)
+(define-key global-map (vector ?\s-m ?d) #'flymake-show-buffer-diagnostics)
+(define-key global-map (vector ?\s-m ?n) #'flymake-goto-next-error)
+(define-key global-map (vector ?\s-m ?p) #'flymake-goto-prev-error)
+
+(provide 'flymake-conf)
+;;; flymake-conf.el ends here
diff --git a/init.el b/init.el
index 0369728..d02b525 100644
--- a/init.el
+++ b/init.el
@@ -259,7 +259,8 @@ no effect."
;;; Eshell
(load-after-function eshell "eshell-conf.el" "Load Eshell and launch it." nil
- (eshell))
+ (eshell)
+ (eshell-start-track-command-time))
;;; tab configurations
@@ -321,6 +322,7 @@ no effect."
(prefix-numeric-value current-prefix-arg)))))
(define-key global-map (vector 3 ?v ?w) #'eww)
+(define-key global-map (vector ?\s-w) #'eww)
;;; Viewing things
@@ -329,6 +331,7 @@ no effect."
;;; flymake
(prepare-in-hook-once prepare-flymake prog-mode-hook "flymake-conf.el")
+(define-key global-map (vector ?\s-m) #'prepare-flymake)
;;; Don't let s-q quit as I oft press that by accident.