summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authortslil clingman <>2021-07-02 17:41:10 -0400
committertslil clingman <>2021-07-02 17:41:10 -0400
commit443664ccf6c91a7061af449f38aef526ede5cbb7 (patch)
tree070b3442ff91301307219a916a3e54b3fecd526a /emacs
parent8281c600a8d712f2045dfc48f4bc17c21d135cc3 (diff)
custom abbreviate directory on modeline + consult-line as isearch
Diffstat (limited to 'emacs')
-rw-r--r--emacs/inits/02-modeline.el79
-rw-r--r--emacs/inits/11-completion.el22
2 files changed, 27 insertions, 74 deletions
diff --git a/emacs/inits/02-modeline.el b/emacs/inits/02-modeline.el
index e4fef10..e5c21a1 100644
--- a/emacs/inits/02-modeline.el
+++ b/emacs/inits/02-modeline.el
@@ -1,4 +1,4 @@
-;; Time-stamp: <2020-05-05 20:25:50 (tslil@bison)>
+;; Time-stamp: <2021-07-02 17h41 EDT (hobbies)>
;; -----------------------------------------------------------------------------
;; Mode-line
@@ -6,6 +6,12 @@
;; The mode-line is set to eliminate duplicate information between buffers.
;; Everything else is intended to be displayed in another, centralised location.
+(defun abbreviate-left-trim-path (p len)
+ (let ((pa (abbreviate-file-name p)))
+ (if (> (length pa) (+ 3 len))
+ (format "...%s" (substring pa (- (length pa) len)))
+ pa)))
+
(setq display-time-format "%d/%H.%M"
display-time-default-load-average nil)
(display-time-mode 1)
@@ -16,79 +22,10 @@
mode-line-modified "%@"
" %l:%c %[" mode-line-buffer-identification "%] %I"
" " mode-line-modes ;; (vc-mode vc-mode)
- (:eval (abbreviate-file-name default-directory))
+ (:eval (abbreviate-left-trim-path default-directory 20))
mode-line-misc-info mode-line-end-spaces))
;; -----------------------------------------------------------------------------
-;; System information
-;;
-;; If running under exwm with its system tray, then put the clock and workspace
-;; indicator in a posfrmae as provided by statusbar.el. Othewrise, use
-;; minibuffer-line as the central location.
-
-(unless (fboundp 'exwm-systemtray-enable)
- ;; First we define two ``modules'' for use in the mode-line
-
- ;; -----------------------------------------------------------------------------
- ;; Remind me of my mortality
-
- (defvar my-mortality "")
-
- (defun my-mortality-update ()
- (setq my-mortality
- (format "%.4f"
- (/ (float-time
- (time-subtract (current-time)
- (encode-time 0 0 0 DAY MONTH YEAR)))
- (* 60 60 24 364.25)))))
-
-
- (defvar my-mortality-update-timer (run-at-time nil (* 60 60) 'my-mortality-update))
-
- ;; -----------------------------------------------------------------------------
- ;; Battery status and CPU temperature
-
- (defvar sys-status "")
- (defvar sys-status-cpu-temp-threshold "45")
-
- (defun linux-sys-status ()
- (let ((bat-s (string-trim (shell-command-to-string (expand-file-name "~/.local/bin/battery"))))
- (temp-s (if (not (file-exists-p "/sys/class/thermal/thermal_zone1/temp")) ""
- (with-temp-buffer
- (insert-file-contents "/sys/class/thermal/thermal_zone1/temp")
- (let ((temp (substring-no-properties (buffer-string) 0 -4)))
- (if (string-greaterp temp sys-status-cpu-temp-threshold)
- (concat " " temp "C") ""))))))
- (if (and (string-blank-p bat-s) (string-blank-p temp-s))
- "" (format " [%s%s]" bat-s temp-s))))
-
- (defun sys-status-update ()
- (setq sys-status (linux-sys-status)))
-
- (defvar sys-status-update-timer (run-at-time nil 60 'sys-status-update))
-
- ;; -----------------------------------------------------------------------------
- ;; Minibuffer-line
-
- (use-package minibuffer-line
- :ensure t
- :config
- (setq minibuffer-line-refresh-interval 60
- minibuffer-line-format
- '("" display-time-string " " my-mortality sys-status))
- ;; We redefine this function to centre the text
- ;; Is there a better way?
- (defun minibuffer-line--update ()
- (with-current-buffer minibuffer-line--buffer
- (erase-buffer)
- (insert (format-mode-line minibuffer-line-format 'minibuffer-line))
- (setq fill-column (frame-width))
- (center-line)))
- (minibuffer-line-mode 1))
- ;; really want to hook buffer changes at all, and focus
- (add-hook 'minibuffer-exit-hook #'minibuffer-line--update))
-
-;; -----------------------------------------------------------------------------
;; Minions to clean mode-line
(use-package minions
diff --git a/emacs/inits/11-completion.el b/emacs/inits/11-completion.el
index 0206324..06296cf 100644
--- a/emacs/inits/11-completion.el
+++ b/emacs/inits/11-completion.el
@@ -1,4 +1,4 @@
-;; Time-stamp: <2021-06-29 17h26 EDT (hobbies)>
+;; Time-stamp: <2021-07-02 17h40 EDT (hobbies)>
;; -----------------------------------------------------------------------------
;; Vertico
@@ -64,7 +64,8 @@
;; M-g bindings (goto-map)
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
- ("M-g g" . consult-line) ;; orig. goto-line
+ ("C-s" . consult-line) ;; orig. goto-line
+ ("C-r" . isearch-forward-regexp)
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
@@ -73,7 +74,7 @@
("M-g I" . consult-project-imenu)
;; M-s bindings (search-map)
("M-s f" . consult-find)
- ("M-s L" . consult-locate)
+ ("M-s L" . consult-locate)
("C-c g" . consult-ripgrep)
("C-c G" . consult-git-grep)
("M-s l" . consult-line)
@@ -112,6 +113,21 @@
consult--source-file consult--source-project-file consult--source-bookmark
:preview-key (kbd "M-."))
+ (defun previous-history-or-next ()
+ (interactive)
+ (if (string= "" (minibuffer-contents-no-properties))
+ (progn
+ (previous-history-element 1)
+ (end-of-line))
+ (vertico-next)))
+
+ (defvar my-consult-line-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-s" #'previous-history-or-next)
+ map))
+
+ (consult-customize consult-line :keymap my-consult-line-map)
+
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; (kbd "C-+")