about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--emacs.el493
1 files changed, 288 insertions, 205 deletions
diff --git a/emacs.el b/emacs.el index d810323..4b39c26 100644 --- a/emacs.el +++ b/emacs.el
@@ -22,6 +22,40 @@
22 22
23;;; Definitions: 23;;; Definitions:
24 24
25(defun renz/sort-by-alpha-length (elems)
26 "Sort ELEMS first alphabetically, then by length."
27 (sort elems (lambda (c1 c2)
28 (or (string-version-lessp c1 c2)
29 (< (length c1) (length c2))))))
30
31(defun renz/sort-by-history (elems)
32 "Sort ELEMS by minibuffer history.
33Use `mct-sort-sort-by-alpha-length' if no history is available."
34 (if-let ((hist (and (not (eq minibuffer-history-variable t))
35 (symbol-value minibuffer-history-variable))))
36 (minibuffer--sort-by-position hist elems)
37 (renz/sort-by-alpha-length elems)))
38
39(defun renz/completion-category ()
40 "Return completion category."
41 (when-let ((window (active-minibuffer-window)))
42 (with-current-buffer (window-buffer window)
43 (completion-metadata-get
44 (completion-metadata (buffer-substring-no-properties
45 (minibuffer-prompt-end)
46 (max (minibuffer-prompt-end) (point)))
47 minibuffer-completion-table
48 minibuffer-completion-predicate)
49 'category))))
50
51(defun renz/sort-multi-category (elems)
52 "Sort ELEMS per completion category."
53 (pcase (renz/completion-category)
54 ('nil elems) ; no sorting
55 ('kill-ring elems)
56 ('project-file (renz/sort-by-alpha-length elems))
57 (_ (renz/sort-by-history elems))))
58
25(defun reset-faces () 59(defun reset-faces ()
26 (dolist (face '(font-lock-regexp-face 60 (dolist (face '(font-lock-regexp-face
27 font-lock-builtin-face 61 font-lock-builtin-face
@@ -169,40 +203,6 @@ N spaces."
169 (setopt tab-bar-show t) 203 (setopt tab-bar-show t)
170 (tab-bar-mode)) 204 (tab-bar-mode))
171 205
172(defun renz/sort-by-alpha-length (elems)
173 "Sort ELEMS first alphabetically, then by length."
174 (sort elems (lambda (c1 c2)
175 (or (string-version-lessp c1 c2)
176 (< (length c1) (length c2))))))
177
178(defun renz/sort-by-history (elems)
179 "Sort ELEMS by minibuffer history.
180Use `mct-sort-sort-by-alpha-length' if no history is available."
181 (if-let ((hist (and (not (eq minibuffer-history-variable t))
182 (symbol-value minibuffer-history-variable))))
183 (minibuffer--sort-by-position hist elems)
184 (renz/sort-by-alpha-length elems)))
185
186(defun renz/completion-category ()
187 "Return completion category."
188 (when-let ((window (active-minibuffer-window)))
189 (with-current-buffer (window-buffer window)
190 (completion-metadata-get
191 (completion-metadata (buffer-substring-no-properties
192 (minibuffer-prompt-end)
193 (max (minibuffer-prompt-end) (point)))
194 minibuffer-completion-table
195 minibuffer-completion-predicate)
196 'category))))
197
198(defun renz/sort-multi-category (elems)
199 "Sort ELEMS per completion category."
200 (pcase (renz/completion-category)
201 ('nil elems) ; no sorting
202 ('kill-ring elems)
203 ('project-file (renz/sort-by-alpha-length elems))
204 (_ (renz/sort-by-history elems))))
205
206(defvar no-tabs-modes '(emacs-lisp-mode 206(defvar no-tabs-modes '(emacs-lisp-mode
207 lisp-mode 207 lisp-mode
208 scheme-mode 208 scheme-mode
@@ -290,6 +290,17 @@ With prefix ARG, toggle the value of
290(put 'browse-url-browser-function 'safe-local-variable 290(put 'browse-url-browser-function 'safe-local-variable
291 'browse-url-browser-function-safe-p) 291 'browse-url-browser-function-safe-p)
292 292
293(defmacro comment (message &rest _ignore)
294 "Comment out lisp forms.
295MESSAGE is for documentation purposes."
296 (declare (indent 1))
297 t)
298
299(defmacro uncomment (message &rest body)
300 "Uncomment a commented form."
301 (declare (indent 1))
302 `(progn ,@body))
303
293 304
294;;; Packages: 305;;; Packages:
295 306
@@ -297,29 +308,36 @@ With prefix ARG, toggle the value of
297(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) 308(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
298(package-initialize) 309(package-initialize)
299 310
300(defun ensure-package (pkg &optional localp) 311(defun ensure-package (pkg &optional local require)
301 "Esnure PKG is installed from repositories. 312 "Esnure PKG is installed from repositories.
302If LOCALP is t, add ~/src/PKG.el to `load-path'. 313If LOCAL is t, add ~/src/PKG.el to `load-path'.
303If LOCALP is a string, add that directory to the `load-path'." 314If LOCAL is a string, add that directory to the `load-path'.
315If REQUIRE is a non-nil value, require the package after adding it."
304 (cond 316 (cond
305 ((stringp localp) 317 ((stringp local)
306 (and (file-exists-p localp) 318 (cond
307 (add-to-list 'load-path localp))) 319 ((file-exists-p local)
308 (localp 320 (add-to-list 'load-path local))
321 (t (user-error "File does not exist: %s" local))))
322 (local
309 (ensure-package pkg 323 (ensure-package pkg
310 (expand-file-name 324 (expand-file-name
311 (format "~/src/%s.el" 325 (format "~/src/%s.el"
312 (symbol-name pkg))))) 326 (symbol-name pkg)))
327 require))
313 (:else 328 (:else
314 (unless (package-installed-p pkg) 329 (unless (package-installed-p pkg)
315 (unless (ignore-errors (package-install pkg)) 330 (unless (ignore-errors (package-install pkg))
316 (package-refresh-contents) 331 (package-refresh-contents)
317 (package-install pkg)))))) 332 (package-install pkg)))))
333 (when require
334 (require pkg))
335 pkg)
318 336
319;; Install packages here. Acutal configuration is done in the Configuration 337;; Install packages here. Acutal configuration is done in the Configuration
320;; section. 338;; section.
321(ensure-package 'consult) 339(ensure-package 'consult nil t)
322(ensure-package 'marginalia) 340(ensure-package 'marginalia nil t)
323(ensure-package 'visual-fill-column) 341(ensure-package 'visual-fill-column)
324(ensure-package 'adaptive-wrap) 342(ensure-package 'adaptive-wrap)
325(ensure-package 'geiser) 343(ensure-package 'geiser)
@@ -438,9 +456,9 @@ If LOCALP is a string, add that directory to the `load-path'."
438 456
439(tool-bar-mode -1) 457(tool-bar-mode -1)
440 458
441(setopt modus-themes-bold-constructs nil 459(setopt modus-themes-bold-constructs nil)
442 modus-themes-italic-constructs t 460(setopt modus-themes-italic-constructs t)
443 modus-themes-variable-pitch-ui t) 461(setopt modus-themes-variable-pitch-ui t)
444 462
445(add-hook 'modus-themes-after-load-theme-hook #'reset-faces) 463(add-hook 'modus-themes-after-load-theme-hook #'reset-faces)
446(add-hook 'after-init-hook #'reset-faces) 464(add-hook 'after-init-hook #'reset-faces)
@@ -454,19 +472,32 @@ If LOCALP is a string, add that directory to the `load-path'."
454 472
455;;; Mode line 473;;; Mode line
456 474
457(defvar mode-line-position 475(setq mode-line-modes
458 '("" 476 (let ((recursive-edit-help-echo
459 (:propertize 477 "Recursive edit, type M-C-c to get out"))
460 ("" 478 (list (propertize "%[" 'help-echo recursive-edit-help-echo)
461 (:eval (if line-number-mode "%3l" "")) 479 `(:propertize ("" mode-name)
462 (:eval (if column-number-mode 480 help-echo "Major mode\n\
463 (if column-number-indicator-zero-based 481mouse-1: Display major mode menu\n\
464 "/%2c" 482mouse-2: Show help for major mode\n\
465 "/%2C") 483mouse-3: Toggle minor modes"
466 ""))) 484 face bold
467 display (min-width (3.0))) 485 mouse-face mode-line-highlight
468 (:propertize (" [" (-3 "%p") "] ") 486 local-map ,mode-line-major-mode-keymap)
469 display (min-width (6.0))))) 487 '("" mode-line-process)
488 `(:propertize ("" minor-mode-alist)
489 mouse-face mode-line-highlight
490 help-echo "Minor mode\n\
491mouse-1: Display minor mode menu\n\
492mouse-2: Show help for minor mode\n\
493mouse-3: Toggle minor modes"
494 local-map ,mode-line-minor-mode-keymap)
495 (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer"
496 'mouse-face 'mode-line-highlight
497 'local-map (make-mode-line-mouse-map
498 'mouse-2 #'mode-line-widen))
499 (propertize "%]" 'help-echo recursive-edit-help-echo)
500 " ")))
470 501
471(setopt mode-line-format 502(setopt mode-line-format
472 '(("%e" 503 '(("%e"
@@ -478,10 +509,13 @@ If LOCALP is a string, add that directory to the `load-path'."
478 display (min-width (3.0))) 509 display (min-width (3.0)))
479 " " 510 " "
480 mode-line-buffer-identification 511 mode-line-buffer-identification
481 (vc-mode (" (" (:eval (string-trim vc-mode)) ")")) 512 (vc-mode
513 (" (" (:eval (string-trim vc-mode)) ")"))
482 " " 514 " "
483 (mode-line-position mode-line-position) 515 (mode-line-position
484 mode-line-modes 516 (" - " mode-line-position))
517 " - "
518 mode-line-modes ; the one above
485 mode-line-misc-info 519 mode-line-misc-info
486 mode-line-end-spaces))) 520 mode-line-end-spaces)))
487 521
@@ -494,48 +528,6 @@ If LOCALP is a string, add that directory to the `load-path'."
494 (lambda () 528 (lambda ()
495 (setf (alist-get minor-mode minor-mode-alist) (list ""))))) 529 (setf (alist-get minor-mode minor-mode-alist) (list "")))))
496 530
497;;; Completion & minibuffer
498
499(fido-vertical-mode)
500(minibuffer-depth-indicate-mode)
501
502(setopt completion-auto-help (not icomplete-mode)
503 completion-auto-select 'second-tab
504 completions-header-format nil
505 completions-max-height 12
506 completions-format 'one-column
507 completion-styles '(basic partial-completion emacs22 flex)
508 completion-ignore-case t
509 read-buffer-completion-ignore-case t
510 read-file-name-completion-ignore-case t
511 completions-detailed t
512 enable-recursive-minibuffers t
513 file-name-shadow-properties '(invisible t intangible t)
514 minibuffer-eldef-shorten-default t
515 minibuffer-prompt-properties '( read-only t
516 cursor-intangible t
517 face minibuffer-prompt)
518 window-resize-pixelwise t
519 frame-resize-pixelwise t)
520
521(add-hook 'completion-list-mode-hook #'truncate-lines-mode)
522(add-hook 'minibuffer-setup-hook #'truncate-lines-mode)
523
524;; Up/down when completing in the minibuffer
525;; (define-key minibuffer-local-map (kbd "C-p") #'minibuffer-previous-completion)
526;; (define-key minibuffer-local-map (kbd "C-n") #'minibuffer-next-completion)
527
528;; Up/down when competing in a normal buffer
529;; (define-key completion-in-region-mode-map (kbd "C-p") #'minibuffer-previous-completion)
530;; (define-key completion-in-region-mode-map (kbd "C-n") #'minibuffer-next-completion)
531
532(setopt completions-sort #'renz/sort-multi-category)
533
534(setopt tab-always-indent 'complete)
535
536(file-name-shadow-mode)
537(minibuffer-electric-default-mode)
538
539(scroll-bar-mode -1) 531(scroll-bar-mode -1)
540(menu-bar-mode -1) 532(menu-bar-mode -1)
541 533
@@ -567,8 +559,8 @@ If LOCALP is a string, add that directory to the `load-path'."
567 559
568 560
569(with-eval-after-load 'visual-fill-column 561(with-eval-after-load 'visual-fill-column
570 (setopt visual-fill-column-center-text t 562 (setopt visual-fill-column-center-text t)
571 visual-fill-column-width (+ fill-column 2)) 563 (setopt visual-fill-column-width (+ fill-column 2))
572 (advice-add 'text-scale-adjust :after #'visual-fill-column-adjust)) 564 (advice-add 'text-scale-adjust :after #'visual-fill-column-adjust))
573(add-hook 'visual-line-mode-hook #'visual-fill-column-mode) 565(add-hook 'visual-line-mode-hook #'visual-fill-column-mode)
574(add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode) 566(add-hook 'visual-line-mode-hook #'adaptive-wrap-prefix-mode)
@@ -583,35 +575,32 @@ If LOCALP is a string, add that directory to the `load-path'."
583(unless (boundp 'use-short-answers) 575(unless (boundp 'use-short-answers)
584 (fset 'yes-or-no-p 'y-or-n-p)) 576 (fset 'yes-or-no-p 'y-or-n-p))
585 577
586(setopt read-answer-short t 578(setopt read-answer-short t)
587 use-dialog-box nil 579(setopt use-dialog-box nil)
588 use-file-dialog nil 580(setopt use-file-dialog nil)
589 use-short-answers t) 581(setopt use-short-answers t)
590
591(require 'savehist) 582(require 'savehist)
592(setopt history-length 1024 583(setopt history-length 1024)
593 history-delete-duplicates t 584(setopt history-delete-duplicates t)
594 ;; savehist-file (etc/ "savehist.el") 585(setopt savehist-save-minibuffer-history t)
595 savehist-save-minibuffer-history t 586(setopt savehist-autosave-interval 30)
596 savehist-autosave-interval 30)
597(savehist-mode) 587(savehist-mode)
598 588
599;; Killing and yanking 589;; Killing and yanking
600(setopt kill-do-not-save-duplicates t 590(setopt kill-do-not-save-duplicates t)
601 kill-read-only-ok t 591(setopt kill-read-only-ok t)
602 ;; XXX: This setting causes an error message the first time it's 592;; XXX: This setting causes an error message the first time it's called:
603 ;; called: "Selection owner couldn't convert: TIMESTAMP". I have 593;; "Selection owner couldn't convert: TIMESTAMP". I have absolutely no idea why
604 ;; absolutely no idea why I get this error, but it's generated in 594;; I get this error, but it's generated in `x_get_foreign_selection'. I also
605 ;; `x_get_foreign_selection'. I also can't inhibit the message or 595;; can't inhibit the message or do anything else with it, so for now, I'll just
606 ;; do anything else with it, so for now, I'll just live with the 596;; live with the message.
607 ;; message. 597(setopt save-interprogram-paste-before-kill t)
608 save-interprogram-paste-before-kill t 598(setopt yank-pop-change-selection t)
609 yank-pop-change-selection t)
610(delete-selection-mode) 599(delete-selection-mode)
611 600
612;; Notifying the user 601;; Notifying the user
613(setopt echo-keystrokes 0.01 602(setopt echo-keystrokes 0.01)
614 ring-bell-function #'ignore) 603(setopt ring-bell-function #'ignore)
615 604
616;; Point and mark 605;; Point and mark
617(setopt set-mark-command-repeat-pop t) 606(setopt set-mark-command-repeat-pop t)
@@ -620,9 +609,9 @@ If LOCALP is a string, add that directory to the `load-path'."
620(setopt read-process-output-max (* 10 1024 1024)) 609(setopt read-process-output-max (* 10 1024 1024))
621 610
622;; Startup 611;; Startup
623(setopt inhibit-startup-screen t 612(setopt inhibit-startup-screen t)
624 initial-buffer-choice t 613(setopt initial-buffer-choice t)
625 initial-scratch-message nil) 614(setopt initial-scratch-message nil)
626 615
627(define-advice startup-echo-area-message (:override ()) 616(define-advice startup-echo-area-message (:override ())
628 (if (get-buffer "*Warnings*") 617 (if (get-buffer "*Warnings*")
@@ -630,26 +619,26 @@ If LOCALP is a string, add that directory to the `load-path'."
630 "^_^")) 619 "^_^"))
631 620
632;; Text editing 621;; Text editing
633(setopt fill-column 80 622(setopt fill-column 80)
634 sentence-end-double-space nil 623(setopt sentence-end-double-space nil)
635 tab-width 8 624(setopt tab-width 8)
636 tab-always-indent 'complete) 625(setopt tab-always-indent 'complete)
637(global-so-long-mode) 626(global-so-long-mode)
638 627
639(setopt show-paren-delay 0.01 628(setopt show-paren-delay 0.01)
640 show-paren-style 'parenthesis 629(setopt show-paren-style 'parenthesis)
641 show-paren-when-point-in-periphery t 630(setopt show-paren-when-point-in-periphery t)
642 show-paren-when-point-inside-paren t) 631(setopt show-paren-when-point-inside-paren t)
643(show-paren-mode) 632(show-paren-mode)
644 633
645 634
646;; Encodings 635;; Encodings
647(set-language-environment "UTF-8") 636(set-language-environment "UTF-8")
648(setopt buffer-file-coding-system 'utf-8-unix 637(setopt buffer-file-coding-system 'utf-8-unix)
649 coding-system-for-read 'utf-8-unix 638(setopt coding-system-for-read 'utf-8-unix)
650 coding-system-for-write 'utf-8-unix 639(setopt coding-system-for-write 'utf-8-unix)
651 default-process-coding-system '(utf-8-unix . utf-8-unix) 640(setopt default-process-coding-system '(utf-8-unix . utf-8-unix))
652 locale-coding-system 'utf-8-unix) 641(setopt locale-coding-system 'utf-8-unix)
653(set-charset-priority 'unicode) 642(set-charset-priority 'unicode)
654(prefer-coding-system 'utf-8-unix) 643(prefer-coding-system 'utf-8-unix)
655(set-default-coding-systems 'utf-8-unix) 644(set-default-coding-systems 'utf-8-unix)
@@ -665,30 +654,30 @@ If LOCALP is a string, add that directory to the `load-path'."
665 654
666 655
667;; Files 656;; Files
668(setopt auto-revert-verbose nil 657(setopt auto-revert-verbose nil)
669 global-auto-revert-non-file-buffers t 658(setopt global-auto-revert-non-file-buffers t)
670 create-lockfiles nil 659(setopt create-lockfiles nil)
671 find-file-visit-truename t 660(setopt find-file-visit-truename t)
672 mode-require-final-newline t 661(setopt mode-require-final-newline t)
673 view-read-only t 662(setopt view-read-only t)
674 save-silently t) 663(setopt save-silently t)
675(global-auto-revert-mode) 664(global-auto-revert-mode)
676 665
677(setopt auto-save-default nil 666(setopt auto-save-default nil)
678 auto-save-interval 1 667(setopt auto-save-interval 1)
679 auto-save-no-message t 668(setopt auto-save-no-message t)
680 auto-save-timeout 1 669(setopt auto-save-timeout 1)
681 auto-save-visited-interval 1 670(setopt auto-save-visited-interval 1)
682 remote-file-name-inhibit-auto-save-visited t) 671(setopt remote-file-name-inhibit-auto-save-visited t)
683(add-to-list 'auto-save-file-name-transforms 672(add-to-list 'auto-save-file-name-transforms
684 `(".*" ,(locate-user-emacs-file "auto-save/") t)) 673 `(".*" ,(locate-user-emacs-file "auto-save/") t))
685(auto-save-visited-mode) 674(auto-save-visited-mode)
686 675
687(setopt backup-by-copying t 676(setopt backup-by-copying t)
688 version-control t 677(setopt version-control t)
689 kept-new-versions 8 678(setopt kept-new-versions 8)
690 kept-old-versions 8 679(setopt kept-old-versions 8)
691 delete-old-versions t) 680(setopt delete-old-versions t)
692(setq-default backup-directory-alist 681(setq-default backup-directory-alist
693 `(("^/dev/shm" . nil) 682 `(("^/dev/shm" . nil)
694 ("^/tmp" . nil) 683 ("^/tmp" . nil)
@@ -696,11 +685,10 @@ If LOCALP is a string, add that directory to the `load-path'."
696 ("." . ,(locate-user-emacs-file "backup")))) 685 ("." . ,(locate-user-emacs-file "backup"))))
697 686
698(require 'recentf) 687(require 'recentf)
699(setopt 688(setopt recentf-max-menu-items 500)
700 recentf-max-menu-items 500 689(setopt recentf-max-saved-items nil)
701 recentf-max-saved-items nil ; Save the whole list 690(setopt recentf-auto-cleanup 'mode)
702 recentf-auto-cleanup 'mode 691(setopt recentf-case-fold-search t)
703 recentf-case-fold-search t)
704;; (add-to-list 'recentf-exclude etc/) 692;; (add-to-list 'recentf-exclude etc/)
705(add-to-list 'recentf-exclude "-autoloads.el\\'") 693(add-to-list 'recentf-exclude "-autoloads.el\\'")
706(add-hook 'buffer-list-update-hook #'recentf-track-opened-file) 694(add-hook 'buffer-list-update-hook #'recentf-track-opened-file)
@@ -708,32 +696,28 @@ If LOCALP is a string, add that directory to the `load-path'."
708(recentf-mode) 696(recentf-mode)
709 697
710(require 'saveplace) 698(require 'saveplace)
711(setopt 699(setopt save-place-forget-unreadable-files (eq system-type 'gnu/linux))
712 save-place-forget-unreadable-files (eq system-type
713 'gnu/linux))
714(save-place-mode) 700(save-place-mode)
715 701
716(require 'uniquify) 702(require 'uniquify)
717(setq uniquify-after-kill-buffer-p t 703(setopt uniquify-after-kill-buffer-p t)
718 uniquify-buffer-name-style 'forward 704(setopt uniquify-buffer-name-style 'forward)
719 uniquify-ignore-buffers-re "^\\*" 705(setopt uniquify-ignore-buffers-re "^\\*")
720 uniquify-separator path-separator) 706(setopt uniquify-separator path-separator)
721 707
722(setq-local vc-follow-symlinks t 708(setopt vc-follow-symlinks t)
723 vc-make-backup-files t) 709(setopt vc-make-backup-files t)
724 710
725;; Whitespace 711;; Whitespace
726(require 'whitespace) 712(require 'whitespace)
727(setopt whitespace-style 713(setopt whitespace-style '(face trailing tabs tab-mark))
728 '(face trailing tabs tab-mark))
729(global-whitespace-mode) 714(global-whitespace-mode)
730(add-hook 'before-save-hook #'delete-trailing-whitespace-except-current-line) 715(add-hook 'before-save-hook #'delete-trailing-whitespace-except-current-line)
731 716
732;; Native compilation 717;; Native compilation
733(setopt native-comp-async-report-warnings-errors 'silent 718(setopt native-comp-async-report-warnings-errors 'silent)
734 native-comp-deferred-compilation t 719(setopt native-comp-deferred-compilation t)
735 native-compile-target-directory 720(setopt native-compile-target-directory (locate-user-emacs-file "eln"))
736 (locate-user-emacs-file "eln"))
737(when (boundp 'native-comp-eln-load-path) 721(when (boundp 'native-comp-eln-load-path)
738 (add-to-list 'native-comp-eln-load-path native-compile-target-directory)) 722 (add-to-list 'native-comp-eln-load-path native-compile-target-directory))
739(when (fboundp 'startup-redirect-eln-cache) 723(when (fboundp 'startup-redirect-eln-cache)
@@ -759,19 +743,18 @@ If LOCALP is a string, add that directory to the `load-path'."
759(add-to-list 'tab-bar-format 'tab-bar-format-align-right :append) 743(add-to-list 'tab-bar-format 'tab-bar-format-align-right :append)
760(add-to-list 'tab-bar-format 'tab-bar-format-global :append) 744(add-to-list 'tab-bar-format 'tab-bar-format-global :append)
761(add-to-list 'tab-bar-format 'tab-bar-end-space :append) 745(add-to-list 'tab-bar-format 'tab-bar-end-space :append)
762;;(setopt tab-bar-show t)
763;;(tab-bar-mode) ; done after setting fonts
764 746
765;;; Org mode 747;;; Org mode
766 748
767(keymap-global-set "C-c a" #'org-agenda) 749(keymap-global-set "C-c a" #'org-agenda)
768(keymap-global-set "C-c c" #'org-capture) 750(keymap-global-set "C-c c" #'org-capture)
769(setopt org-clock-clocked-in-display 'frame-title 751(setopt org-clock-clocked-in-display 'mode-line)
770 org-clock-frame-title-format 752(setopt org-clock-string-limit 24)
771 '("%b" " - " (t org-mode-line-string)) 753(setopt org-clock-out-remove-zero-time-clocks t)
772 org-tags-column (- (- fill-column 3)) 754(setopt org-clock-frame-title-format '("%b" " - " (t org-mode-line-string)))
773 org-log-into-drawer t 755(setopt org-tags-column (- (- fill-column 3)))
774 org-clock-into-drawer t) 756(setopt org-log-into-drawer t)
757(setopt org-clock-into-drawer t)
775 758
776;;; Spelling 759;;; Spelling
777 760
@@ -953,16 +936,16 @@ ORG-EXPORT-ARGS are passed to `org-export-to-buffer'."
953(undohist-initialize) 936(undohist-initialize)
954 937
955(require 'hungry-delete) 938(require 'hungry-delete)
956(setopt hungry-delete-chars-to-skip " \t" 939(setopt hungry-delete-chars-to-skip " \t")
957 hungry-delete-skip-regexp (format "[%s]" hungry-delete-chars-to-skip) 940(setopt hungry-delete-skip-regexp (format "[%s]" hungry-delete-chars-to-skip))
958 hungry-delete-join-reluctantly nil) 941(setopt hungry-delete-join-reluctantly nil)
959(add-to-list 'hungry-delete-except-modes 'eshell-mode) 942(add-to-list 'hungry-delete-except-modes 'eshell-mode)
960(add-to-list 'hungry-delete-except-modes 'nim-mode) 943(add-to-list 'hungry-delete-except-modes 'nim-mode)
961(add-to-list 'hungry-delete-except-modes 'python-mode) 944(add-to-list 'hungry-delete-except-modes 'python-mode)
962(global-hungry-delete-mode) 945(global-hungry-delete-mode)
963 946
964(setopt avy-background t 947(setopt avy-background t)
965 avy-keys (string-to-list "asdfghjklqwertyuiopzxcvbnm")) 948(setopt avy-keys (string-to-list "asdfghjklqwertyuiopzxcvbnm"))
966(keymap-global-set "M-j" #'avy-goto-char-timer) 949(keymap-global-set "M-j" #'avy-goto-char-timer)
967(keymap-set isearch-mode-map "M-j" #'avy-isearch) 950(keymap-set isearch-mode-map "M-j" #'avy-isearch)
968(keymap-global-set "M-z" #'zzz-to-char) 951(keymap-global-set "M-z" #'zzz-to-char)
@@ -993,12 +976,15 @@ ORG-EXPORT-ARGS are passed to `org-export-to-buffer'."
993(keymap-set isearch-mode-map "M-s e" #'consult-isearch-history) 976(keymap-set isearch-mode-map "M-s e" #'consult-isearch-history)
994(keymap-set isearch-mode-map "M-s l" #'consult-line) 977(keymap-set isearch-mode-map "M-s l" #'consult-line)
995 978
996(keymap-set minibuffer-local-map "M-n" #'consult-history) 979(setopt xref-show-xrefs-function #'consult-xref)
997(keymap-set minibuffer-local-map "M-p" #'consult-history) 980(setopt xref-show-definitions-function #'consult-xref)
998 981
999(setopt completion-in-region-function #'consult-completion-in-region 982(setopt consult-preview-key "M-.")
1000 xref-show-xrefs-function #'consult-xref 983
1001 xref-show-definitions-function #'consult-xref) 984(consult-customize
985 consult-ripgrep consult-git-grep consult-grep
986 consult-xref
987 :preview-key '(:debounce 0.4 any))
1002 988
1003(setopt initial-scratch-message ";;; Emacs!\n\n") 989(setopt initial-scratch-message ";;; Emacs!\n\n")
1004 990
@@ -1029,9 +1015,9 @@ ORG-EXPORT-ARGS are passed to `org-export-to-buffer'."
1029 1015
1030(require 'anzu) 1016(require 'anzu)
1031(global-anzu-mode) 1017(global-anzu-mode)
1032(setopt search-default-mode t 1018(setopt search-default-mode t)
1033 anzu-mode-lighter "" 1019(setopt anzu-mode-lighter "")
1034 anzu-deactivate-region t) 1020(setopt anzu-deactivate-region t)
1035 1021
1036(global-set-key [remap query-replace] #'anzu-query-replace-regexp) 1022(global-set-key [remap query-replace] #'anzu-query-replace-regexp)
1037(global-set-key [remap query-replace-regexp] #'anzu-query-replace) 1023(global-set-key [remap query-replace-regexp] #'anzu-query-replace)
@@ -1039,3 +1025,100 @@ ORG-EXPORT-ARGS are passed to `org-export-to-buffer'."
1039 #'anzu-isearch-query-replace-regexp) 1025 #'anzu-isearch-query-replace-regexp)
1040(define-key isearch-mode-map [remap isearch-query-replace-regexp] 1026(define-key isearch-mode-map [remap isearch-query-replace-regexp]
1041 #'anzu-isearch-query-replace) 1027 #'anzu-isearch-query-replace)
1028
1029;;; Completion & minibuffer
1030
1031(minibuffer-depth-indicate-mode)
1032(setopt tab-always-indent 'complete)
1033(file-name-shadow-mode)
1034(minibuffer-electric-default-mode)
1035
1036(setopt completion-styles '(flex basic partial-completion emacs22))
1037(setopt completion-ignore-case t)
1038(setopt read-buffer-completion-ignore-case t)
1039(setopt read-file-name-completion-ignore-case t)
1040(setopt completions-detailed t)
1041(setopt enable-recursive-minibuffers t)
1042(setopt file-name-shadow-properties '(invisible t intangible t))
1043(setopt minibuffer-eldef-shorten-default t)
1044(setopt minibuffer-prompt-properties
1045 '(read-only t cursor-intangible t face minibuffer-prompt))
1046(setopt window-resize-pixelwise t)
1047(setopt frame-resize-pixelwise t)
1048
1049(add-hook 'completion-list-mode-hook #'truncate-lines-mode)
1050(add-hook 'minibuffer-setup-hook #'truncate-lines-mode)
1051
1052(define-minor-mode good-completions-mode
1053 "A mode for completing good."
1054 :lighter ""
1055 :global t
1056 (setq completion-auto-help (when good-completions-mode 'always)
1057 completion-auto-select (when good-completions-mode 'second-tab)
1058 completions-format 'one-column
1059 completions-header-format nil)
1060 (cond
1061 (good-completions-mode
1062 ;; Turn off other completion frameworks
1063 (icomplete-mode -1)
1064 (icomplete-vertical-mode -1)
1065 (fido-mode -1)
1066 (fido-vertical-mode -1)
1067 ;; Up/down when completing in the minibuffer
1068 (define-key minibuffer-local-map (kbd "C-p")
1069 #'minibuffer-previous-completion)
1070 (define-key minibuffer-local-map (kbd "C-n")
1071 #'minibuffer-next-completion)
1072 ;; Up/down when competing in a normal buffer
1073 (define-key completion-in-region-mode-map (kbd "C-p")
1074 #'minibuffer-previous-completion)
1075 (define-key completion-in-region-mode-map (kbd "C-n")
1076 #'minibuffer-next-completion))
1077 (setq completions-sort #'renz/sort-multi-category
1078 completion-in-region-function #'completion--in-region)
1079 (t)))
1080
1081(good-completions-mode)
1082
1083(comment "Unnecessary after being defined."
1084 (ensure-package 'wiki-abbrev t t)
1085 (wiki-abbrev-insinuate))
1086(add-hook 'text-mode-hook #'abbrev-mode)
1087
1088;;; Browser
1089
1090(setopt browse-url-browser-function #'eww-browse-url)
1091
1092;; External browsers: firefox > chromium > chrome
1093(setq browse-url-firefox-program
1094 (or (executable-find "firefox")
1095 (executable-find "firefox-esr"))
1096 browse-url-firefox-new-window-is-tab t
1097 browse-url-firefox-arguments '("--new-tab")
1098
1099 browse-url-chromium-program
1100 (or (executable-find "chromium")
1101 (executable-find "chromium-browser"))
1102
1103 browse-url-chrome-program
1104 (or (executable-find "chrome")
1105 (executable-find "google-chrome-stable"))
1106
1107 browse-url-secondary-browser-function
1108 (cond (browse-url-firefox-program #'browse-url-firefox)
1109 (browse-url-chromium-program #'browse-url-chromium)
1110 (browse-url-chrome-program #'browse-url-chrome)
1111 (t #'browse-url-default-browser)))
1112
1113(ensure-package 'link-hint)
1114(setopt link-hint-avy-style 'at-full)
1115(setopt link-hint-avy-all-windows t)
1116
1117(defvar link-hint-map
1118 (define-keymap
1119 :name "Open a link"
1120 :prefix 'link-hint-map
1121 "M-l" #'link-hint-open-link
1122 "M-w" #'link-hint-copy-link))
1123
1124(keymap-global-set "M-l" 'link-hint-map)