commit 3d0ea9df6fe8419d2d5f33d060e0a862c738ffad parent a9b94619c0c112680f9480b0c45734f9af4bfe1a Author: Vincent Demeester <vincent@sbr.pm> Date: Tue, 7 Apr 2020 12:28:17 +0200 emacs: renaming files Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
24 files changed, 513 insertions(+), 539 deletions(-)
diff --git a/docs/emacs.org b/docs/emacs.org @@ -498,7 +498,7 @@ the =Ubuntu= font are not available on the system, I am just letting Emacs start with its default font. -#+INCLUDE: "../tools/emacs/config/appearance.el" src emacs-lisp :range-begin "TypeFaceConfiguration" :range-end "-TypeFaceConfiguration" :lines "6-45" +#+INCLUDE: "../tools/emacs/config/config-appearance.el" src emacs-lisp :range-begin "TypeFaceConfiguration" :range-end "-TypeFaceConfiguration" :lines "6-45" ** Typeface suitability test :PROPERTIES: @@ -601,7 +601,7 @@ ** Org-mode (personal information manager) :PROPERTIES: -:header-args: :tangle config/setup-org.el +:header-args: :tangle config/config-org.el :CUSTOM_ID: h:c8fd2624-6c91-4b89-9645-4261ca85d584 :END: @@ -646,7 +646,7 @@ First, let's define some basic constants, mainly on how my main =org= folder is organized. -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgConstants" :range-end "-OrgConstants" :lines "7-18" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgConstants" :range-end "-OrgConstants" :lines "7-18" In a nutshell, I am currently trying the following organization, with =~/desktop/org/= as the base of almost all =org-mode= things: @@ -677,7 +677,7 @@ =inbox.org=. For this, we can use the emacs [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Registers.html][registers]] and more accurately the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/File-Registers.html#File-Registers][file registers]]. -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgRegisters" :range-end "-OrgRegisters" :lines "21-26" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgRegisters" :range-end "-OrgRegisters" :lines "21-26" With this, I can jump to the inbox with ~C-x r j i~, to the journal using ~C-x r j j~, โฆ @@ -770,7 +770,7 @@ /The =ensure org-plus-contrib= is there to make sure I am loading the =org= module from my nix configuration and not the built-in =org= module (that might lag in terms of version)/ -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgMain" :range-end "-OrgMain" :lines "29-104" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgMain" :range-end "-OrgMain" :lines "29-104" I've set-up an =org-mode= hook to add few modes to the default setup. - I am really annoyed by trailing white-space so I want them to be shown @@ -779,15 +779,15 @@ + I turn on =auto-revert-mode= so that the buffer is always up-to-date. + I like to have header indented, so I'm enabling =org-indent-mode=. -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgHook" :range-end "-OrgHook" :lines "107-116" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgHook" :range-end "-OrgHook" :lines "107-116" Let's also use =org-id=โฆ -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgId" :range-end "-OrgId" :lines "119-148" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgId" :range-end "-OrgId" :lines "119-148" โฆ and =org-crypt= (for encrypted =org-mode= files). -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCrypt" :range-end "-OrgCrypt" :lines "151-156" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCrypt" :range-end "-OrgCrypt" :lines "151-156" **** TODO Refiling :PROPERTIES: @@ -822,11 +822,11 @@ agenda views. This allows to group things and overall set-up the agenda view I want. This agenda view uses the =n= key. -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgAgenda" :range-end "-OrgAgenda" :lines "159-208" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgAgenda" :range-end "-OrgAgenda" :lines "159-208" Let's try to get my work calendar entries in my agenda too. It is a little bit tricky ๐ผ. -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgGcal" :range-end "-OrgGcal" :lines "211-225" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgGcal" :range-end "-OrgGcal" :lines "211-225" *** Habits :ATTACH: :PROPERTIES: @@ -858,14 +858,14 @@ [[./images/2020-02-29-14-41-59.png]] -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgHabit" :range-end "-OrgHabit" :lines "228-233" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgHabit" :range-end "-OrgHabit" :lines "228-233" *** TODO Sources :PROPERTIES: :CUSTOM_ID: h:82c3b800-9d80-408d-b3b6-54dc15b0590c :END: -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgSrc" :range-end "-OrgSrc" :lines "236-243" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgSrc" :range-end "-OrgSrc" :lines "236-243" *** TODO Capture :PROPERTIES: @@ -882,7 +882,7 @@ options. This is very interesting when you want to group some capture template together (like templates related to /work/, โฆ). -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureStart" :range-end "-OrgCaptureStart" :lines "246-250" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureStart" :range-end "-OrgCaptureStart" :lines "246-250" Some of my capture template are big and hard to read if embedded in the =emacs-lisp= code. The good thing is that =org-mode= is able to load the template from files too ๐. @@ -890,44 +890,44 @@ Here is a list of my templates: - Default :: Store a link (mainly used with =org-protocol=) and take a random note - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureOldTemplate" :range-end "-OrgCaptureOldTemplate" :lines "253-262" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureOldTemplate" :range-end "-OrgCaptureOldTemplate" :lines "253-262" - Tasks :: /work/ task, like reviewing a PR, or cleaning a folder. - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureTask" :range-end "-OrgCaptureTask" :lines "265-277" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureTask" :range-end "-OrgCaptureTask" :lines "265-277" - journaling :: As I use =org-mode= for my /journal/ too, I need capture entry for it. I currently have two types of journal entry : - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureJournalBase" :range-end "-OrgCaptureJournalBase" :lines "280-282" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureJournalBase" :range-end "-OrgCaptureJournalBase" :lines "280-282" + standard: one title and some text #+INCLUDE: "../tools/emacs/etc/orgmode/journal.org" src org - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureJournalEntry" :range-end "-OrgCaptureJournalEntry" :lines "285-292" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureJournalEntry" :range-end "-OrgCaptureJournalEntry" :lines "285-292" + worklog: related to work, to be able to say what I did, what I wanted to do, problems, โฆ during the daily #+INCLUDE: "../tools/emacs/etc/orgmode/worklog.org" src org - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureWorklog" :range-end "-OrgCaptureWorklog" :lines "295-300" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureWorklog" :range-end "-OrgCaptureWorklog" :lines "295-300" - weekly review :: each and every week, I am going through this item to make my review of the week. #+INCLUDE: "../tools/emacs/etc/orgmode/weekly.org" src org - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureWeekly" :range-end "-OrgCaptureWeekly" :lines "303-308" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureWeekly" :range-end "-OrgCaptureWeekly" :lines "303-308" - blog posts :: - #+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureBlog" :range-end "-OrgCaptureBlog" :lines "318-320" + #+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureBlog" :range-end "-OrgCaptureBlog" :lines "318-320" -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgCaptureEnd" :range-end "-OrgCaptureEnd" :lines "323-324" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgCaptureEnd" :range-end "-OrgCaptureEnd" :lines "323-324" -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgProtocol" :range-end "-OrgProtocol" :lines "327-329" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgProtocol" :range-end "-OrgProtocol" :lines "327-329" *** Clocking :PROPERTIES: @@ -947,36 +947,35 @@ In addition to that workflow, I want to switch the state of the task to =STARTED= when I am clocking-in, if it's not already =STARTED=. -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgClock" :range-end "-OrgClock" :lines "332-425" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgClock" :range-end "-OrgClock" :lines "332-425" *** TODO Links :PROPERTIES: :CUSTOM_ID: h:afc81fbb-f7a0-401c-8b56-19f51edebd88 :END: -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgAttach" :range-end "-OrgAttach" :lines "428-433" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgAttach" :range-end "-OrgAttach" :lines "428-433" -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgLinks" :range-end "-OrgLinks" :lines "436-461" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgLinks" :range-end "-OrgLinks" :lines "436-461" *** TODO Litterate programming :PROPERTIES: :CUSTOM_ID: h:b5f6beba-6195-4ff0-a194-502ac2a9e3da :END: -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgBabel" :range-end "-OrgBabel" :lines "464-523" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgBabel" :range-end "-OrgBabel" :lines "464-523" *** TODO Exporting :PROPERTIES: :CUSTOM_ID: h:afad00e0-367c-4c7b-b191-e3ed72be754b :END: -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgExportConstants" :range-end "-OrgExportConstants" :lines "526-528" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgExportConstants" :range-end "-OrgExportConstants" :lines "526-528" -#+INCLUDE: "../tools/emacs/config/setup-org.el" src emacs-lisp :range-begin "OrgExportCfg" :range-end "-OrgExportCfg" :lines "531-542" +#+INCLUDE: "../tools/emacs/config/config-org.el" src emacs-lisp :range-begin "OrgExportCfg" :range-end "-OrgExportCfg" :lines "531-542" ** TODO Email and newsgroup :PROPERTIES: -:header-args: :tangle config/setup-mails.el :CUSTOM_ID: h:afa562d5-b07e-413b-8c1d-2d489fb72900 :END: @@ -1002,7 +1001,7 @@ Before configuring any email client, we need to establish some essentials: who we are, where our credentials are stored and whether encryption is supported. -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "AuthSource" :range-end "-AuthSource" :lines "4-9" +#+INCLUDE: "../tools/emacs/config/config-mails.el" src emacs-lisp :range-begin "AuthSource" :range-end "-AuthSource" :lines "4-9" *** Gnus :PROPERTIES: @@ -1202,16 +1201,16 @@ :CUSTOM_ID: h:8cd8c972-ba38-40c2-b30f-68a4233593d6 :END: -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "SendmailCfg" :range-end "-SendmailCfg" :lines "22-38" +#+INCLUDE: "../tools/emacs/config/config-mails.el" src emacs-lisp :range-begin "SendmailCfg" :range-end "-SendmailCfg" :lines "22-38" -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "MessageCfg" :range-end "-MessageCfg" :lines "41-52" +#+INCLUDE: "../tools/emacs/config/config-mails.el" src emacs-lisp :range-begin "MessageCfg" :range-end "-MessageCfg" :lines "41-52" *** TODO ~notmuch~ configuration :PROPERTIES: :CUSTOM_ID: h:b67b377e-0fbc-4237-857c-641cdf2de1cf :END: -#+INCLUDE: "../tools/emacs/config/setup-mails.el" src emacs-lisp :range-begin "Notmuch" :range-end "-Notmuch" :lines "55-72" +#+INCLUDE: "../tools/emacs/config/config-mails.el" src emacs-lisp :range-begin "Notmuch" :range-end "-Notmuch" :lines "55-72" * User interface and interactions :PROPERTIES: diff --git a/tools/emacs/config/appearance.el b/tools/emacs/config/config-appearance.el diff --git a/tools/emacs/config/setup-buffers.el b/tools/emacs/config/config-buffers.el diff --git a/tools/emacs/config/setup-compile.el b/tools/emacs/config/config-compile.el diff --git a/tools/emacs/config/config-completion.el b/tools/emacs/config/config-completion.el @@ -0,0 +1,318 @@ +;;; setup-completion.el --- -*- lexical-binding: t -*- +;;; Commentary: +;;; Setup completion framework +;;; Code +(use-package minibuffer + :config + (setq completion-cycle-threshold 3) + (setq completion-flex-nospace nil) + (setq completion-pcm-complete-word-inserts-delimiters t) + (setq completion-pcm-word-delimiters "-_./:| ") + ;; NOTE: flex completion is introduced in Emacs 27 + (setq completion-show-help nil) + (setq completion-styles '(partial-completion substring initials flex)) + (setq completion-category-overrides + '((file (styles initials basic)) + (buffer (styles initials basic)) + (info-menu (styles basic)))) + (setq completions-format 'vertical) ; *Completions* buffer + (setq enable-recursive-minibuffers t) + (setq read-answer-short t) + (setq read-buffer-completion-ignore-case t) + (setq read-file-name-completion-ignore-case t) + (setq resize-mini-windows t) + + (file-name-shadow-mode 1) + (minibuffer-depth-indicate-mode 1) + (minibuffer-electric-default-mode 1) + + (defun vde/focus-minibuffer () + "Focus the active minibuffer. + +Bind this to `completion-list-mode-map' to M-v to easily jump +between the list of candidates present in the \\*Completions\\* +buffer and the minibuffer (because by default M-v switches to the +completions if invoked from inside the minibuffer." + (interactive) + (let ((mini (active-minibuffer-window))) + (when mini + (select-window mini)))) + + (defun vde/focus-minibuffer-or-completions () + "Focus the active minibuffer or the \\*Completions\\*. + +If both the minibuffer and the Completions are present, this +command will first move per invocation to the former, then the +latter, and then continue to switch between the two. + +The continuous switch is essentially the same as running +`vde/focus-minibuffer' and `switch-to-completions' in +succession." + (interactive) + (let* ((mini (active-minibuffer-window)) + (completions (get-buffer-window "*Completions*"))) + (cond ((and mini + (not (minibufferp))) + (select-window mini nil)) + ((and completions + (not (eq (selected-window) + completions))) + (select-window completions nil))))) + + ;; Technically, this is not specific to the minibuffer, but I define + ;; it here so that you can see how it is also used from inside the + ;; "Completions" buffer + (defun vde/describe-symbol-at-point (&optional arg) + "Get help (documentation) for the symbol at point. + +With a prefix argument, switch to the *Help* window. If that is +already focused, switch to the most recently used window +instead." + (interactive "P") + (let ((symbol (symbol-at-point))) + (when symbol + (describe-symbol symbol))) + (when current-prefix-arg + (let ((help (get-buffer-window "*Help*"))) + (when help + (if (not (eq (selected-window) help)) + (select-window help) + (select-window (get-mru-window))))))) + + ;; Defines, among others, aliases for common actions to Super-KEY. + ;; Normally these should go in individual package declarations, but + ;; their grouping here makes things easier to understand. + :bind (("M-v" . vde/focus-minibuffer-or-completions) + :map completion-list-mode-map + ("h" . vde/describe-symbol-at-point) + ("n" . next-line) + ("p" . previous-line) + ("f" . next-completion) + ("b" . previous-completion) + ("M-v" . vde/focus-minibuffer))) + +(use-package icomplete + :demand + :after minibuffer ; Read that section as well + :config + (setq icomplete-delay-completions-threshold 0) + (setq icomplete-max-delay-chars 0) + (setq icomplete-compute-delay 0) + (setq icomplete-show-matches-on-no-input t) + (setq icomplete-hide-common-prefix nil) + (setq icomplete-prospects-height 1) + (setq icomplete-separator " ยท ") ; mid dot, not full stop + (setq icomplete-with-completion-tables t) + (setq icomplete-in-buffer t) + + (fido-mode -1) ; Emacs 27.1 + (icomplete-mode 1) + + (defun vde/icomplete-force-complete-and-exit () + "Complete the current `icomplete' match and exit the minibuffer. + +Contrary to `icomplete-force-complete-and-exit', this will +confirm your choice without complaining about incomplete matches. + +Those incomplete matches can block you from performing legitimate +actions, such as defining a new tag in an `org-capture' prompt. + +In my testing, this is necessary when the variable +`icomplete-with-completion-tables' is non-nil, because then +`icomplete' will be activated practically everywhere it can." + (interactive) + (icomplete-force-complete) + (exit-minibuffer)) + + (defun vde/icomplete-kill-ring-save (&optional arg) + "Expand and save current `icomplete' match to the kill ring. + +With a prefix argument, insert the match to the point in the +current buffer and switch focus back to the minibuffer." + (interactive "*P") + (when (and (minibufferp) + (bound-and-true-p icomplete-mode)) + (icomplete-force-complete) + (kill-new (field-string-no-properties)) + (when current-prefix-arg + (kill-new (field-string-no-properties)) + (select-window (get-mru-window)) + (insert (car kill-ring)) + (vde/focus-minibuffer)))) + + (defun vde/icomplete-toggle-completion-styles (&optional arg) + "Toggle between flex and prefix matching. + +With pregix ARG use basic completion instead. These styles are +described in `completion-styles-alist'. + +Bind this function in `icomplete-minibuffer-map'." + (interactive "*P") + (when (and (minibufferp) + (bound-and-true-p icomplete-mode)) + (let* ((completion-styles-original completion-styles) + (basic '(emacs22 basic)) + (flex '(flex initials substring partial-completion)) + (prefix '(partial-completion substring initials flex))) + (if current-prefix-arg + (progn + (setq-local completion-styles basic) + (message "%s" (propertize "Prioritising BASIC matching" 'face 'highlight))) + (if (not (eq (car completion-styles) 'flex)) + (progn + (setq-local completion-styles flex) + (message "%s" (propertize "Prioritising FLEX matching" 'face 'highlight))) + (setq-local completion-styles prefix) + (message "%s" (propertize "Prioritising PREFIX matching" 'face 'highlight))))))) + + (defun vde/switch-buffer (arg) + "Custom switch to buffer. +With universal argument ARG or when not in project, rely on +`switch-to-buffer'. +Otherwise, use `projectile-switch-to-project'." + (interactive "P") + (if (or arg (not (projectile-project-p))) + (call-interactively 'switch-to-buffer) + (projectile-switch-to-buffer))) + + :bind (:map icomplete-minibuffer-map + ("C-m" . minibuffer-complete-and-exit) ; force current input + ("C-n" . icomplete-forward-completions) + ("<right>" . icomplete-forward-completions) + ("<down>" . icomplete-forward-completions) + ("C-p" . icomplete-backward-completions) + ("<left>" . icomplete-backward-completions) + ("<up>" . icomplete-backward-completions) + ("<return>" . vde/icomplete-force-complete-and-exit) + ("M-o w" . vde/icomplete-kill-ring-save) + ("M-o i" . (lambda () + (interactive) + (let ((current-prefix-arg t)) + (vde/icomplete-kill-ring-save)))) + ("C-M-," . vde/icomplete-toggle-completion-styles) + ("C-M-." . (lambda () + (interactive) + (let ((current-prefix-arg t)) + (vde/icomplete-toggle-completion-styles)))))) + +(use-package ivy + :disabled + :bind (("C-x B" . ivy-switch-buffer) + :map ivy-occur-mode-map + ("f" . forward-char) + ("b" . backward-char) + ("n" . ivy-occur-next-line) + ("p" . ivy-occur-previous-line) + ("<C-return>" . ivy-occur-press)) + :hook + (ivy-occur-mode . hl-line-mode) + :config + (setq ivy-count-format "%d/%d " + ivy-height-alist '((t lambda (_caller) (/ (window-height) 4))) + ivy-use-virtual-buffers t + ivy-virtual-abbreviate 'full ;Show the full virtual file paths + ivy-wrap nil + ivy-re-builders-alist '((counsel-M-x . ivy--regex-fuzzy) + (t . ivy--regex-plus)) + ivy-display-style 'fancy + ivy-use-selectable-prompt t + ivy-fixed-height-minibuffer nil + ivy-extra-directories '("../" "./") + ) + (ivy-set-occur 'ivy-switch-buffer 'ivy-switch-buffer-occur) + (ivy-set-occur 'swiper 'swiper-occur) + (ivy-set-occur 'swiper-isearch 'swiper-occur)) + +(use-package counsel + :disabled + :after ivy + :bind (("M-i" . counsel-semantic-or-imenu) + ("C-x C-r" . counsel-recentf) + ("C-M-y" . counsel-yank-pop) + ("C-h F" . counsel-faces) ;Overrides `Info-goto-emacs-command-node' + ("C-h S" . counsel-info-lookup-symbol) + ("C-c u" . counsel-unicode-char) + ("C-c C" . counsel-colors-emacs) ;Alternative to `list-colors-display' + ("M-s r" . counsel-rg) + ("M-s g" . counsel-git-grep) + :map ivy-minibuffer-map + ("C-r" . counsel-minibuffer-history) + ("C-SPC" . ivy-restrict-to-matches)) + :config + (setq counsel-yank-pop-preselect-last t + counsel-yank-pop-separator "\nโโโโโโโโโ\n" + counsel-find-file-at-point t) + (progn + (ivy-set-actions + 'counsel-find-file + `(("x" + (lambda (x) (delete-file (expand-file-name x ivy--directory))) + ,(propertize "delete" 'face 'font-lock-warning-face)))) + + ;; counsel-rg + ;; Redefine `counsel-rg-base-command' with my required options, especially + ;; the `--follow' option to allow search through symbolic links (part of + ;; `modi/rg-arguments'). + (setq counsel-rg-base-command + (concat (mapconcat #'shell-quote-argument + (append '("rg") + vde/rg-arguments + '("--no-heading" ;No file names above matching content + )) + " ") + " %s" ;This MUST be %s, not %S + ;https://github.com/abo-abo/swiper/issues/427 + )))) + +(use-package company + :disabled + :commands global-company-mode + :init + (add-hook 'after-init-hook #'global-company-mode) + (setq + company-idle-delay 0.2 + company-selection-wrap-around t + company-minimum-prefix-length 2 + company-require-match nil + company-dabbrev-ignore-case nil + company-dabbrev-downcase nil + company-show-numbers t + company-tooltip-align-annotations t) + :config + (bind-keys :map company-active-map + ("C-d" . company-show-doc-buffer) + ("C-l" . company-show-location) + ("C-n" . company-select-next) + ("C-p" . company-select-previous) + ("C-t" . company-select-next) + ("C-s" . company-select-previous) + ("TAB" . company-complete)) + (setq company-backends + '(company-css + company-clang + company-capf + company-semantic + company-xcode + company-cmake + company-files + company-gtags + company-etags + company-keywords))) + +(use-package company-emoji + :disabled + :after company + :config + (add-to-list 'company-backends 'company-emoji)) + +;;; Default rg arguments +;; https://github.com/BurntSushi/ripgrep +(defconst vde/rg-arguments + `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore' + "--line-number" ;Line numbers + "--smart-case" + "--max-columns" "150" ;Emacs doesn't handle long line lengths very well + "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME"))) + "Default rg arguments used in the functions in `counsel' and `projectile' packages.") + +(provide 'setup-completion) diff --git a/tools/emacs/config/setup-dired.el b/tools/emacs/config/config-dired.el diff --git a/tools/emacs/config/setup-editing.el b/tools/emacs/config/config-editing.el diff --git a/tools/emacs/config/setup-files.el b/tools/emacs/config/config-files.el diff --git a/tools/emacs/config/02-help.el b/tools/emacs/config/config-help.el diff --git a/tools/emacs/config/setup-keybindings.el b/tools/emacs/config/config-keybindings.el diff --git a/tools/emacs/config/setup-mails.el b/tools/emacs/config/config-mails.el diff --git a/tools/emacs/config/setup-navigating.el b/tools/emacs/config/config-navigating.el diff --git a/tools/emacs/config/setup-org.el b/tools/emacs/config/config-org.el diff --git a/tools/emacs/config/setup-projectile.el b/tools/emacs/config/config-projects.el diff --git a/tools/emacs/config/setup-search.el b/tools/emacs/config/config-search.el diff --git a/tools/emacs/config/setup-shells.el b/tools/emacs/config/config-shells.el diff --git a/tools/emacs/config/config-vcs.el b/tools/emacs/config/config-vcs.el @@ -0,0 +1,163 @@ +;;; config-vcs.el --- -*- lexical-binding: t; -*- +;;; Commentary: +;;; Version control configuration +;;; Code: + +;; UseVC +(use-package vc + :config + (setq-default vc-find-revision-no-save t + vc-follow-symlinks t) + :bind (("C-x v f" . vc-log-incoming) ; git fetch + ("C-x v F" . vc-update) + ("C-x v d" . vc-diff))) +;; -UseVC + +;; UseVCDir +(use-package vc-dir + :config + (defun vde/vc-dir-project () + "Unconditionally display `vc-diff' for the current project." + (interactive) + (vc-dir (vc-root-dir))) + + (defun vde/vc-dir-jump () + "Jump to present directory in a `vc-dir' buffer." + (interactive) + (vc-dir default-directory)) + :bind (("C-x v p" . vde/vc-dir-project) + ("C-x v j" . vde/vc-dir-jump) ; similar to `dired-jump' + :map vc-dir-mode-map + ("f" . vc-log-incoming) ; replaces `vc-dir-find-file' (use RET) + ("F" . vc-update) ; symmetric with P: `vc-push' + ("d" . vc-diff) ; align with D: `vc-root-diff' + ("k" . vc-dir-clean-files))) +;; -UseVCDir + +;; UseVCGit +(use-package vc-git + :config + (setq vc-git-diff-switches "--patch-with-stat") + (setq vc-git-print-log-follow t)) +;; -UseVCGit + +;; UseVCAnnotate +(use-package vc-annotate + :config + (setq vc-annotate-display-mode 'scale) ; scale to oldest + :bind (("C-x v a" . vc-annotate) ; `vc-update-change-log' is not in git + :map vc-annotate-mode-map + ("t" . vc-annotate-toggle-annotation-visibility))) +;; -UseVcAnnotate + +(use-package magit ; The best Git client out there + :disabled + :bind (("C-c v c" . magit-clone) + ("C-c v C" . magit-checkout) + ("C-c v d" . magit-dispatch-popup) + ("C-c v g" . magit-blame) + ("C-c v l" . magit-log-buffer-file) + ("C-c v p" . magit-pull) + ("C-c v v" . magit-status)) + :config + (setq-default magit-save-repository-buffers 'dontask + magit-refs-show-commit-count 'all + magit-branch-prefer-remote-upstream '("master") + magit-display-buffer-function #'magit-display-buffer-traditional + magit-completing-read-function 'ivy-completing-read) + + (magit-define-popup-option 'magit-rebase-popup + ?S "Sign using gpg" "--gpg-sign=" #'magit-read-gpg-secret-key) + (magit-define-popup-switch 'magit-log-popup + ?m "Omit merge commits" "--no-merges") + + ;; Hide "Recent Commits" + (magit-add-section-hook 'magit-status-sections-hook + 'magit-insert-unpushed-to-upstream + 'magit-insert-unpushed-to-upstream-or-recent + 'replace) + + ;; Show refined hunks during diffs + (set-default 'magit-diff-refine-hunk t) + + (add-hook 'projectile-switch-project-hook + #'mu-magit-set-repo-dirs-from-projectile) + + ;; Refresh `magit-status' after saving a buffer + (add-hook 'after-save-hook #'magit-after-save-refresh-status) + + ;; Free C-c C-w for Eyebrowse + (unbind-key "C-c C-w" git-commit-mode-map) ) +(put 'magit-diff-edit-hunk-commit 'disabled nil) + +(use-package git-commit ; Git commit message mode + :disabled + :defer 2 + :init (global-git-commit-mode) + :config + (setq git-commit-summary-max-length 50) + (setq git-commit-known-pseudo-headers + '("Signed-off-by" + "Acked-by" + "Modified-by" + "Cc" + "Suggested-by" + "Reported-by" + "Tested-by" + "Reviewed-by")) + (setq git-commit-style-convention-checks + '(non-empty-second-line + overlong-summary-line)) + (remove-hook 'git-commit-finish-query-functions + #'git-commit-check-style-conventions)) + +(use-package gitconfig-mode ; Git configuration mode + :disabled + :defer 2) + +(use-package gitignore-mode ; .gitignore mode + :disabled + :defer 2) + +(use-package gitattributes-mode ; Git attributes mode + :disabled + :defer 2) + +(use-package dired-git-info + :disabled + :bind (:map dired-mode-map + (")" . dired-git-info-mode)) + :defer 2) + +(use-package ediff + :disabled + :config + (setq ediff-window-setup-function 'ediff-setup-windows-plain) + (setq ediff-split-window-function 'split-window-horizontally) + (setq ediff-diff-options "-w") + (add-hook 'ediff-after-quit-hook-internal 'winner-undo)) + +(defun git-blame-line () + "Runs `git blame` on the current line and + adds the commit id to the kill ring" + (interactive) + (let* ((line-number (save-excursion + (goto-char (point-at-bol)) + (+ 1 (count-lines 1 (point))))) + (line-arg (format "%d,%d" line-number line-number)) + (commit-buf (generate-new-buffer "*git-blame-line-commit*"))) + (call-process "git" nil commit-buf nil + "blame" (buffer-file-name) "-L" line-arg) + (let* ((commit-id (with-current-buffer commit-buf + (buffer-substring 1 9))) + (log-buf (generate-new-buffer "*git-blame-line-log*"))) + (kill-new commit-id) + (call-process "git" nil log-buf nil + "log" "-1" "--pretty=%h %an %s" commit-id) + (with-current-buffer log-buf + (message "Line %d: %s" line-number (buffer-string))) + (kill-buffer log-buf)) + (kill-buffer commit-buf))) + +(provide 'setup-vcs) +;;; setup-vcs.el ends here diff --git a/tools/emacs/config/setup-windows.el b/tools/emacs/config/config-windows.el diff --git a/tools/emacs/config/setup-docker.el b/tools/emacs/config/programming-docker.el diff --git a/tools/emacs/config/setup-go.el b/tools/emacs/config/programming-go.el diff --git a/tools/emacs/config/setup-nix.el b/tools/emacs/config/programming-nix.el diff --git a/tools/emacs/config/setup-completion.el b/tools/emacs/config/setup-completion.el @@ -1,318 +0,0 @@ -;;; setup-completion.el --- -*- lexical-binding: t -*- -;;; Commentary: -;;; Setup completion framework -;;; Code -(use-package minibuffer - :config - (setq completion-cycle-threshold 3) - (setq completion-flex-nospace nil) - (setq completion-pcm-complete-word-inserts-delimiters t) - (setq completion-pcm-word-delimiters "-_./:| ") - ;; NOTE: flex completion is introduced in Emacs 27 - (setq completion-show-help nil) - (setq completion-styles '(partial-completion substring initials flex)) - (setq completion-category-overrides - '((file (styles initials basic)) - (buffer (styles initials basic)) - (info-menu (styles basic)))) - (setq completions-format 'vertical) ; *Completions* buffer - (setq enable-recursive-minibuffers t) - (setq read-answer-short t) - (setq read-buffer-completion-ignore-case t) - (setq read-file-name-completion-ignore-case t) - (setq resize-mini-windows t) - - (file-name-shadow-mode 1) - (minibuffer-depth-indicate-mode 1) - (minibuffer-electric-default-mode 1) - - (defun vde/focus-minibuffer () - "Focus the active minibuffer. - -Bind this to `completion-list-mode-map' to M-v to easily jump -between the list of candidates present in the \\*Completions\\* -buffer and the minibuffer (because by default M-v switches to the -completions if invoked from inside the minibuffer." - (interactive) - (let ((mini (active-minibuffer-window))) - (when mini - (select-window mini)))) - - (defun vde/focus-minibuffer-or-completions () - "Focus the active minibuffer or the \\*Completions\\*. - -If both the minibuffer and the Completions are present, this -command will first move per invocation to the former, then the -latter, and then continue to switch between the two. - -The continuous switch is essentially the same as running -`vde/focus-minibuffer' and `switch-to-completions' in -succession." - (interactive) - (let* ((mini (active-minibuffer-window)) - (completions (get-buffer-window "*Completions*"))) - (cond ((and mini - (not (minibufferp))) - (select-window mini nil)) - ((and completions - (not (eq (selected-window) - completions))) - (select-window completions nil))))) - - ;; Technically, this is not specific to the minibuffer, but I define - ;; it here so that you can see how it is also used from inside the - ;; "Completions" buffer - (defun vde/describe-symbol-at-point (&optional arg) - "Get help (documentation) for the symbol at point. - -With a prefix argument, switch to the *Help* window. If that is -already focused, switch to the most recently used window -instead." - (interactive "P") - (let ((symbol (symbol-at-point))) - (when symbol - (describe-symbol symbol))) - (when current-prefix-arg - (let ((help (get-buffer-window "*Help*"))) - (when help - (if (not (eq (selected-window) help)) - (select-window help) - (select-window (get-mru-window))))))) - - ;; Defines, among others, aliases for common actions to Super-KEY. - ;; Normally these should go in individual package declarations, but - ;; their grouping here makes things easier to understand. - :bind (("M-v" . vde/focus-minibuffer-or-completions) - :map completion-list-mode-map - ("h" . vde/describe-symbol-at-point) - ("n" . next-line) - ("p" . previous-line) - ("f" . next-completion) - ("b" . previous-completion) - ("M-v" . vde/focus-minibuffer))) - -(use-package icomplete - :demand - :after minibuffer ; Read that section as well - :config - (setq icomplete-delay-completions-threshold 0) - (setq icomplete-max-delay-chars 0) - (setq icomplete-compute-delay 0) - (setq icomplete-show-matches-on-no-input t) - (setq icomplete-hide-common-prefix nil) - (setq icomplete-prospects-height 1) - (setq icomplete-separator " ยท ") ; mid dot, not full stop - (setq icomplete-with-completion-tables t) - (setq icomplete-in-buffer t) - - (fido-mode -1) ; Emacs 27.1 - (icomplete-mode 1) - - (defun vde/icomplete-force-complete-and-exit () - "Complete the current `icomplete' match and exit the minibuffer. - -Contrary to `icomplete-force-complete-and-exit', this will -confirm your choice without complaining about incomplete matches. - -Those incomplete matches can block you from performing legitimate -actions, such as defining a new tag in an `org-capture' prompt. - -In my testing, this is necessary when the variable -`icomplete-with-completion-tables' is non-nil, because then -`icomplete' will be activated practically everywhere it can." - (interactive) - (icomplete-force-complete) - (exit-minibuffer)) - - (defun vde/icomplete-kill-ring-save (&optional arg) - "Expand and save current `icomplete' match to the kill ring. - -With a prefix argument, insert the match to the point in the -current buffer and switch focus back to the minibuffer." - (interactive "*P") - (when (and (minibufferp) - (bound-and-true-p icomplete-mode)) - (icomplete-force-complete) - (kill-new (field-string-no-properties)) - (when current-prefix-arg - (kill-new (field-string-no-properties)) - (select-window (get-mru-window)) - (insert (car kill-ring)) - (vde/focus-minibuffer)))) - - (defun vde/icomplete-toggle-completion-styles (&optional arg) - "Toggle between flex and prefix matching. - -With pregix ARG use basic completion instead. These styles are -described in `completion-styles-alist'. - -Bind this function in `icomplete-minibuffer-map'." - (interactive "*P") - (when (and (minibufferp) - (bound-and-true-p icomplete-mode)) - (let* ((completion-styles-original completion-styles) - (basic '(emacs22 basic)) - (flex '(flex initials substring partial-completion)) - (prefix '(partial-completion substring initials flex))) - (if current-prefix-arg - (progn - (setq-local completion-styles basic) - (message "%s" (propertize "Prioritising BASIC matching" 'face 'highlight))) - (if (not (eq (car completion-styles) 'flex)) - (progn - (setq-local completion-styles flex) - (message "%s" (propertize "Prioritising FLEX matching" 'face 'highlight))) - (setq-local completion-styles prefix) - (message "%s" (propertize "Prioritising PREFIX matching" 'face 'highlight))))))) - - (defun vde/switch-buffer (arg) - "Custom switch to buffer. -With universal argument ARG or when not in project, rely on -`switch-to-buffer'. -Otherwise, use `projectile-switch-to-project'." - (interactive "P") - (if (or arg (not (projectile-project-p))) - (switch-to-buffer) - (projectile-switch-to-buffer))) - - :bind (:map icomplete-minibuffer-map - ("C-m" . minibuffer-complete-and-exit) ; force current input - ("C-n" . icomplete-forward-completions) - ("<right>" . icomplete-forward-completions) - ("<down>" . icomplete-forward-completions) - ("C-p" . icomplete-backward-completions) - ("<left>" . icomplete-backward-completions) - ("<up>" . icomplete-backward-completions) - ("<return>" . vde/icomplete-force-complete-and-exit) - ("M-o w" . vde/icomplete-kill-ring-save) - ("M-o i" . (lambda () - (interactive) - (let ((current-prefix-arg t)) - (vde/icomplete-kill-ring-save)))) - ("C-M-," . vde/icomplete-toggle-completion-styles) - ("C-M-." . (lambda () - (interactive) - (let ((current-prefix-arg t)) - (vde/icomplete-toggle-completion-styles)))))) - -(use-package ivy - :disabled - :bind (("C-x B" . ivy-switch-buffer) - :map ivy-occur-mode-map - ("f" . forward-char) - ("b" . backward-char) - ("n" . ivy-occur-next-line) - ("p" . ivy-occur-previous-line) - ("<C-return>" . ivy-occur-press)) - :hook - (ivy-occur-mode . hl-line-mode) - :config - (setq ivy-count-format "%d/%d " - ivy-height-alist '((t lambda (_caller) (/ (window-height) 4))) - ivy-use-virtual-buffers t - ivy-virtual-abbreviate 'full ;Show the full virtual file paths - ivy-wrap nil - ivy-re-builders-alist '((counsel-M-x . ivy--regex-fuzzy) - (t . ivy--regex-plus)) - ivy-display-style 'fancy - ivy-use-selectable-prompt t - ivy-fixed-height-minibuffer nil - ivy-extra-directories '("../" "./") - ) - (ivy-set-occur 'ivy-switch-buffer 'ivy-switch-buffer-occur) - (ivy-set-occur 'swiper 'swiper-occur) - (ivy-set-occur 'swiper-isearch 'swiper-occur)) - -(use-package counsel - :disabled - :after ivy - :bind (("M-i" . counsel-semantic-or-imenu) - ("C-x C-r" . counsel-recentf) - ("C-M-y" . counsel-yank-pop) - ("C-h F" . counsel-faces) ;Overrides `Info-goto-emacs-command-node' - ("C-h S" . counsel-info-lookup-symbol) - ("C-c u" . counsel-unicode-char) - ("C-c C" . counsel-colors-emacs) ;Alternative to `list-colors-display' - ("M-s r" . counsel-rg) - ("M-s g" . counsel-git-grep) - :map ivy-minibuffer-map - ("C-r" . counsel-minibuffer-history) - ("C-SPC" . ivy-restrict-to-matches)) - :config - (setq counsel-yank-pop-preselect-last t - counsel-yank-pop-separator "\nโโโโโโโโโ\n" - counsel-find-file-at-point t) - (progn - (ivy-set-actions - 'counsel-find-file - `(("x" - (lambda (x) (delete-file (expand-file-name x ivy--directory))) - ,(propertize "delete" 'face 'font-lock-warning-face)))) - - ;; counsel-rg - ;; Redefine `counsel-rg-base-command' with my required options, especially - ;; the `--follow' option to allow search through symbolic links (part of - ;; `modi/rg-arguments'). - (setq counsel-rg-base-command - (concat (mapconcat #'shell-quote-argument - (append '("rg") - vde/rg-arguments - '("--no-heading" ;No file names above matching content - )) - " ") - " %s" ;This MUST be %s, not %S - ;https://github.com/abo-abo/swiper/issues/427 - )))) - -(use-package company - :disabled - :commands global-company-mode - :init - (add-hook 'after-init-hook #'global-company-mode) - (setq - company-idle-delay 0.2 - company-selection-wrap-around t - company-minimum-prefix-length 2 - company-require-match nil - company-dabbrev-ignore-case nil - company-dabbrev-downcase nil - company-show-numbers t - company-tooltip-align-annotations t) - :config - (bind-keys :map company-active-map - ("C-d" . company-show-doc-buffer) - ("C-l" . company-show-location) - ("C-n" . company-select-next) - ("C-p" . company-select-previous) - ("C-t" . company-select-next) - ("C-s" . company-select-previous) - ("TAB" . company-complete)) - (setq company-backends - '(company-css - company-clang - company-capf - company-semantic - company-xcode - company-cmake - company-files - company-gtags - company-etags - company-keywords))) - -(use-package company-emoji - :disabled - :after company - :config - (add-to-list 'company-backends 'company-emoji)) - -;;; Default rg arguments -;; https://github.com/BurntSushi/ripgrep -(defconst vde/rg-arguments - `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore' - "--line-number" ;Line numbers - "--smart-case" - "--max-columns" "150" ;Emacs doesn't handle long line lengths very well - "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME"))) - "Default rg arguments used in the functions in `counsel' and `projectile' packages.") - -(provide 'setup-completion) diff --git a/tools/emacs/config/setup-hydras.el b/tools/emacs/config/setup-hydras.el @@ -1,69 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(when nil - (progn - (defhydra hydra-goto-line (goto-map "") - "goto-line" - ("g" goto-line "go") - ("m" set-mark-command "mark" :bind nil) - ("q" nil "quit")) - - (defhydra hydra-yank-pop () - "yank" - ("C-y" yank nil) - ("M-y" yank-pop nil) - ("y" (yank-pop 1) "next") - ("Y" (yank-pop -1) "prev")) ; or browse-kill-ring - - (defhydra hydra-zoom (global-map "<f2>") - "zoom" - ("g" text-scale-increase "in") - ("l" text-scale-decrease "out") - ("r" (text-scale-set 0) "reset") - ("0" (text-scale-set 0) :bind nil :exit t) - ("1" (text-scale-set 0) nil :bind nil :exit t)) - - ;; Better shrink/enlarge windows - (defhydra hydra-resize (global-map "<f2>") - "resize windows" - ("<up>" enlarge-window "enlarge") - ("<down>" shrink-window "shrink") - ("<left>" shrink-window-horizontally "shrink horizontaly") - ("<right>" enlarge-window-horizontally "enlarge horizontaly")) - - (defvar hide-mode-line-mode nil) - (defvar whitespace-mode nil) - (defvar subword-mode nil) - (defhydra hydra-toggle (:color pink :hint nil) - " -_a_ abbrev-mode: %`abbrev-mode -_b_ subword-mode: %`subword-mode -_d_ debug-on-error: %`debug-on-error -_h_ hide-mode-line-mode %`hide-mode-line-mode -_f_ auto-fill-mode: %`auto-fill-function -_r_ readonly-mode: %`buffer-read-only -_t_ truncate-lines %`truncate-lines -_v_ visual-line-mode: %`visual-line-mode -_w_ whitespace-mode: %`whitespace-mode -_s_ smartparens-strict: %`smartparens-strict-mode -_V_ visible-mode: %`visible-mode -" - ("a" abbrev-mode nil) - ("b" subword-mode nil) - ("d" toggle-debug-on-error nil) - ("f" auto-fill-mode nil) - ("h" hide-mode-line-mode nil) - ("r" dired-toggle-read-only nil) - ("t" toggle-truncate-lines nil) - ("v" visual-line-mode nil) - ("V" visible-mode nil) - ("w" whitespace-mode nil) - ("s" smartparens-strict-mode nil) - ("q" nil "quit")) - - (global-set-key (kbd "C-c C-v") 'hydra-toggle/body) - - (bind-key "M-y" #'hydra-yank-pop/yank-pop) - (bind-key "C-y" #'hydra-yank-pop/yank) - )) - -(provide 'setup-hydras) diff --git a/tools/emacs/config/setup-vcs.el b/tools/emacs/config/setup-vcs.el @@ -1,119 +0,0 @@ -;;; -*- lexical-binding: t; -*- -(use-package vc-hooks ; Simple version control - :disabled - :bind (("S-<f5>" . vc-revert) - ("C-c v r" . vc-refresh-state)) - :config - ;; Always follow symlinks to files in VCS repos - (setq-default vc-follow-symlinks t)) - -(use-package magit ; The best Git client out there - :disabled - :bind (("C-c v c" . magit-clone) - ("C-c v C" . magit-checkout) - ("C-c v d" . magit-dispatch-popup) - ("C-c v g" . magit-blame) - ("C-c v l" . magit-log-buffer-file) - ("C-c v p" . magit-pull) - ("C-c v v" . magit-status)) - :config - (setq-default magit-save-repository-buffers 'dontask - magit-refs-show-commit-count 'all - magit-branch-prefer-remote-upstream '("master") - magit-display-buffer-function #'magit-display-buffer-traditional - magit-completing-read-function 'ivy-completing-read) - - (magit-define-popup-option 'magit-rebase-popup - ?S "Sign using gpg" "--gpg-sign=" #'magit-read-gpg-secret-key) - (magit-define-popup-switch 'magit-log-popup - ?m "Omit merge commits" "--no-merges") - - ;; Hide "Recent Commits" - (magit-add-section-hook 'magit-status-sections-hook - 'magit-insert-unpushed-to-upstream - 'magit-insert-unpushed-to-upstream-or-recent - 'replace) - - ;; Show refined hunks during diffs - (set-default 'magit-diff-refine-hunk t) - - (add-hook 'projectile-switch-project-hook - #'mu-magit-set-repo-dirs-from-projectile) - - ;; Refresh `magit-status' after saving a buffer - (add-hook 'after-save-hook #'magit-after-save-refresh-status) - - ;; Free C-c C-w for Eyebrowse - (unbind-key "C-c C-w" git-commit-mode-map) ) -(put 'magit-diff-edit-hunk-commit 'disabled nil) - -(use-package git-commit ; Git commit message mode - :disabled - :defer 2 - :init (global-git-commit-mode) - :config - (setq git-commit-summary-max-length 50) - (setq git-commit-known-pseudo-headers - '("Signed-off-by" - "Acked-by" - "Modified-by" - "Cc" - "Suggested-by" - "Reported-by" - "Tested-by" - "Reviewed-by")) - (setq git-commit-style-convention-checks - '(non-empty-second-line - overlong-summary-line)) - (remove-hook 'git-commit-finish-query-functions - #'git-commit-check-style-conventions)) - -(use-package gitconfig-mode ; Git configuration mode - :disabled - :defer 2) - -(use-package gitignore-mode ; .gitignore mode - :disabled - :defer 2) - -(use-package gitattributes-mode ; Git attributes mode - :disabled - :defer 2) - -(use-package dired-git-info - :disabled - :bind (:map dired-mode-map - (")" . dired-git-info-mode)) - :defer 2) - -(use-package ediff - :disabled - :config - (setq ediff-window-setup-function 'ediff-setup-windows-plain) - (setq ediff-split-window-function 'split-window-horizontally) - (setq ediff-diff-options "-w") - (add-hook 'ediff-after-quit-hook-internal 'winner-undo)) - -(defun git-blame-line () - "Runs `git blame` on the current line and - adds the commit id to the kill ring" - (interactive) - (let* ((line-number (save-excursion - (goto-char (point-at-bol)) - (+ 1 (count-lines 1 (point))))) - (line-arg (format "%d,%d" line-number line-number)) - (commit-buf (generate-new-buffer "*git-blame-line-commit*"))) - (call-process "git" nil commit-buf nil - "blame" (buffer-file-name) "-L" line-arg) - (let* ((commit-id (with-current-buffer commit-buf - (buffer-substring 1 9))) - (log-buf (generate-new-buffer "*git-blame-line-log*"))) - (kill-new commit-id) - (call-process "git" nil log-buf nil - "log" "-1" "--pretty=%h %an %s" commit-id) - (with-current-buffer log-buf - (message "Line %d: %s" line-number (buffer-string))) - (kill-buffer log-buf)) - (kill-buffer commit-buf))) - -(provide 'setup-vcs)