diff --git a/conf-lisp/magit.el b/conf-lisp/magit.el index ce67d74..aed3f83 100644 --- a/conf-lisp/magit.el +++ b/conf-lisp/magit.el @@ -1,87 +1,102 @@ ;; *** Magit +;; TODO: add blamer.el (https://github.com/Artawower/blamer.el), currently fails to install (2023/05/08) + ;; Not much to say about Magit (use-package magit - :ensure t - :config + :ensure t - (defun tvd-magit-status () - "Always call `magit-status' with prefix arg." - (interactive) - (let ((current-prefix-arg t)) - (call-interactively 'magit-status))) + :init + (use-package magit-todos) - ;; (with-eval-after-load 'info - ;; (info-initialize) - ;; (add-to-list 'Info-directory-list - ;; (expand-file-name (concat "~/.emacs.d/lisp/magit-" - ;; tvd-magit-revision - ;; "/Documentation/")))) - (setq magit-view-git-manual-method 'woman) + :config + (magit-todos-mode) - (defalias 'git 'magit-status) - (defalias 'gitlog 'magit-log-buffer-file) + (defun tvd-magit-status () + "Always call `magit-status' with prefix arg." + (interactive) + (let ((current-prefix-arg t)) + (call-interactively 'magit-status))) - ;; configure magit - (with-eval-after-load 'magit - (dolist (dir (list (expand-file-name "~/dev/D/github") - (expand-file-name "~/fits/git") - (expand-file-name "~/dev"))) - (when (file-exists-p dir) - (add-to-list 'magit-repository-directories (cons dir 1)))) - (setq magit-completing-read-function 'magit-ido-completing-read) + (setq magit-view-git-manual-method 'woman) - ;; use timestamps in log buffers - (setq magit-log-margin '(t "%Y-%m-%d " magit-log-margin-width t 18)) + (defalias 'git 'magit-status) + (defalias 'gitlog 'magit-log-buffer-file) - ;; navigate magit buffers as I do everywhere else, I do not automatically - ;; cycle/decycle though, the magit defaults are absolutely sufficient. - (define-key magit-mode-map (kbd "") 'magit-section-forward-sibling) - (define-key magit-mode-map (kbd "") 'magit-section-backward-sibling) - (define-key magit-mode-map (kbd "") 'magit-delete-thing)) + (defun tvd-magit-cycle-down() + "hide current section, jump down to the next and show it" + (interactive) + (magit-section-hide (magit-current-section)) + (magit-section-forward-sibling) + (magit-section-show (magit-current-section))) - ;; one thing though: on startup it bitches about git version, but it - ;; works nevertheless. So I disable this specific warning. + (defun tvd-magit-cycle-up() + "hide current section, jump up to the next and show it" + (interactive) + (magit-section-hide (magit-current-section)) + (magit-section-backward-sibling) + (magit-section-show (magit-current-section))) - (defun tvd-ignore-magit-warnings-if-any () - (interactive) - (when (get-buffer "*Warnings*") - (with-current-buffer "*Warnings*" - (goto-char (point-min)) - (when (re-search-forward "Magit requires Git >=") - (kill-buffer-and-window))))) + ;; configure magit + (with-eval-after-load 'magit + (dolist (dir (list (expand-file-name "~/dev/D/github") + (expand-file-name "~/fits/git") + (expand-file-name "~/dev"))) + (when (file-exists-p dir) + (add-to-list 'magit-repository-directories (cons dir 1)))) + (setq magit-completing-read-function 'magit-ido-completing-read) - (add-hook 'after-init-hook 'tvd-ignore-magit-warnings-if-any t) + ;; use timestamps in log buffers + (setq magit-log-margin '(t "%Y-%m-%d " magit-log-margin-width t 18)) - ;; now, THIS is the pure genius me: hit "ls in magit-status buffer - ;; and end up in a dired buffer of current repository. The default - ;; binding for this is C-M-i, which is not memorizable, while "ls" - ;; is. That is, 'l' is a prefix command leading to magit-log-popup - ;; and 's' is undefined, which I define here, which then jumps to - ;; dired. - ;; see: https://github.com/magit/magit/wiki/Converting-popup-modifications-to-transient-modifications#adding-an-action - (transient-append-suffix 'magit-log "l" - '("s" "dired" magit-dired-jump)) + ;; navigate magit buffers as I do in org-mode, that is going down + ;; hides the current sibling, and vice versa + (define-key magit-mode-map (kbd "") 'tvd-magit-cycle-down) + (define-key magit-mode-map (kbd "") 'tvd-magit-cycle-up) + (define-key magit-mode-map (kbd "") 'magit-delete-thing)) - ;; after an exhausting discussion on magit#3139 I use this function - ;; to (kind of) switch to another repository from inside magit-status. - (defun tvd-switch-magit-repo () - (interactive) - (let ((dir (magit-read-repository))) - (magit-mode-bury-buffer) - (magit-status dir))) - (define-key magit-mode-map (kbd "C") 'tvd-switch-magit-repo) + ;; one thing though: on startup it bitches about git version, but it + ;; works nevertheless. So I disable this specific warning. - ;; via - ;; http://manuel-uberti.github.io/emacs/2018/02/17/magit-bury-buffer/: - ;; a great enhancement, when closing the magit status buffer, ALL - ;; other possibly still remaining magit buffers will be killed as - ;; well AND the window setup will be restored. - (defun tvd-kill-magit-buffers() - "Restore window setup from before magit and kill all magit buffers." - (interactive) - (let ((buffers (magit-mode-get-buffers))) - (magit-restore-window-configuration) - (mapc #'kill-buffer buffers))) + (defun tvd-ignore-magit-warnings-if-any () + (interactive) + (when (get-buffer "*Warnings*") + (with-current-buffer "*Warnings*" + (goto-char (point-min)) + (when (re-search-forward "Magit requires Git >=") + (kill-buffer-and-window))))) - (define-key magit-status-mode-map (kbd "q") #'tvd-kill-magit-buffers)) + (add-hook 'after-init-hook 'tvd-ignore-magit-warnings-if-any t) + + ;; now, THIS is the pure genius me: hit "ls in magit-status buffer + ;; and end up in a dired buffer of current repository. The default + ;; binding for this is C-M-i, which is not memorizable, while "ls" + ;; is. That is, 'l' is a prefix command leading to magit-log-popup + ;; and 's' is undefined, which I define here, which then jumps to + ;; dired. + ;; see: https://github.com/magit/magit/wiki/Converting-popup-modifications-to-transient-modifications#adding-an-action + (transient-append-suffix 'magit-log "l" + '("s" "dired" magit-dired-jump)) + + ;; after an exhausting discussion on magit#3139 I use this function + ;; to (kind of) switch to another repository from inside magit-status. + (defun tvd-switch-magit-repo () + (interactive) + (let ((dir (magit-read-repository))) + (magit-mode-bury-buffer) + (magit-status dir))) + (define-key magit-mode-map (kbd "C") 'tvd-switch-magit-repo) + + ;; via + ;; http://manuel-uberti.github.io/emacs/2018/02/17/magit-bury-buffer/: + ;; a great enhancement, when closing the magit status buffer, ALL + ;; other possibly still remaining magit buffers will be killed as + ;; well AND the window setup will be restored. + (defun tvd-kill-magit-buffers() + "Restore window setup from before magit and kill all magit buffers." + (interactive) + (let ((buffers (magit-mode-get-buffers))) + (magit-restore-window-configuration) + (mapc #'kill-buffer buffers))) + + (define-key magit-status-mode-map (kbd "q") #'tvd-kill-magit-buffers)) diff --git a/conf-lisp/smartparens.el b/conf-lisp/smartparens.el index 5034de9..94f0774 100644 --- a/conf-lisp/smartparens.el +++ b/conf-lisp/smartparens.el @@ -185,11 +185,11 @@ _k_: kill (C-k) _s_: split _{_: wrap with { } ;; Jump to the beginning of following balanced expression. If ;; there is no following expression on the current level, jump ;; one level up backward, effectively doing sp-backward-up-sexp. - ("C-S-" . 'sp-next-sexp) + ("C-S-" . 'sp-previous-sexp) ;; Jump to the end of the previous balanced expression. If there ;; is no previous expression on the current level, jupm one level ;; up forward, effectively doing sp-up-sexp. - ("C-S-" . 'sp-previous-sexp) + ("C-S-" . 'sp-next-sexp) ;; comment the whole sexp (";" . 'tvd-lisp-comment) diff --git a/init.el b/init.el index d1b9c01..1551129 100644 --- a/init.el +++ b/init.el @@ -164,7 +164,7 @@ '(custom-safe-themes '("7f1d414afda803f3244c6fb4c2c64bea44dac040ed3731ec9d75275b9e831fe5" default)) '(package-selected-packages - '(howm tiny tramp dictcc beacon which-key goto-last-change browse-kill-ring fringe-current-line swiper smex undo-tree fic-mode cmake-mode yaml-mode windresize web-mode use-package tablist solarized-theme smartparens rust-mode projectile persistent-scratch org-bullets markdown-mode magit iedit ibuffer-vc ibuffer-tramp hydra htmlize highlight-indentation go-mode eyebrowse elmacro dumb-jump dired-ranger dired-k dired-filter default-text-scale change-inner buffer-move)) + '(blamer howm tiny tramp dictcc beacon which-key goto-last-change browse-kill-ring fringe-current-line swiper smex undo-tree fic-mode cmake-mode yaml-mode windresize web-mode use-package tablist solarized-theme smartparens rust-mode projectile persistent-scratch org-bullets markdown-mode magit iedit ibuffer-vc ibuffer-tramp hydra htmlize highlight-indentation go-mode eyebrowse elmacro dumb-jump dired-ranger dired-k dired-filter default-text-scale change-inner buffer-move)) '(safe-local-variable-values '((ruby-indent-level 4))) '(warning-suppress-types '((comp))))