Skip to content

Instantly share code, notes, and snippets.

View jamescherti's full-sized avatar

James Cherti jamescherti

View GitHub Profile
@jamescherti
jamescherti / comment-indent-newline.el
Last active August 18, 2024 16:50
Emacs: Enable multi-line commenting and indenting
;; Description: Enable multi-line commenting and indenting in Emacs
;; Gits URL: https://gist.github.com/jamescherti/b8987b3299c0b567f1fdfffc1878a686
;; License: MIT
;; Author: James Cherti
;; Enable multi-line commenting. This allows comments to span multiple lines,
;; which is useful for writing longer comments or docstrings.
(setq comment-multi-line t)
;; Bind the `RET` (Return) key to `comment-indent-new-line`.
@jamescherti
jamescherti / evil-comment-uncomment.el
Created August 13, 2024 13:09
Emacs Evil: Comment or uncomment line or visual selection
;; Description: Emacs Evil: Comment or uncomment line or visual selection
;; Gits URL: https://gist.github.com/jamescherti/2aa95dc674ba024114d25824ddef8d7b
;; License: MIT
(with-eval-after-load "evil"
(evil-define-operator my-evil-comment-or-uncomment (beg end)
"Toggle comment for the region between BEG and END."
(interactive "<r>")
(comment-or-uncomment-region beg end))
(evil-define-key 'normal 'global (kbd "gc") 'my-evil-comment-or-uncomment))
@jamescherti
jamescherti / fix-newline-indent-relative.el
Last active August 6, 2024 03:30
Emacs: Fix issue that prevents `newline-and-indent' from using `indent-relative'
;; Description: Emacs: Fix issue that prevents `newline-and-indent'
;; from using `indent-relative' or `indent-relative-first-indent-point'.
;;
;; Gits URL: https://gist.github.com/jamescherti/d8f23d7c5a0ad8885934fb6dec75138a
;; License: MIT
;; Author: James Cherti
(defun my-indent-relative ()
"Indent the current line based on the indentation of the previous non-blank line.
If the first indentation position of the previous non-blank line is greater than
@jamescherti
jamescherti / vdiff-text-scale.el
Last active July 30, 2024 18:06
Emacs Vdiff: Synchronize the text-scale (font size) across all vdiff buffers
;; Description: Emacs Vdiff: Synchronize the text-scale (font size) across all vdiff buffers
;; Gits URL: https://gist.github.com/jamescherti/e1f64d56dc1e6bffa2fcb9d2ae7b7a83
;; License: MIT
;; Author: James Cherti
(defun my-vdiff-sync-text-scale (&rest args)
"Synchronize the text-scale (font size) across all vdiff buffers."
(when (bound-and-true-p vdiff-mode)
(let ((ts-amount text-scale-mode-amount))
(dolist (window (vdiff--all-windows))
@jamescherti
jamescherti / evil-jinx.el
Last active July 27, 2024 17:12
Emacs Evil: Configure Jinx (spell checker)
;; Description: Emacs Evil: Configure Jinx (spell checker)
;; Gits URL:
;; License: MIT
;; Author: James Cherti
(use-package jinx
:defer t
:commands jinx-mode
:init
@jamescherti
jamescherti / evil-search-no-jump.el
Created July 27, 2024 01:39
Emacs Evil: Start a forward search without jumping to the next item
;; Description: Emacs Evil: Start a forward search without jumping to the next item.
;; Gits URL: https://gist.github.com/jamescherti/867e9fd0ce640107d0fe0d2f58502fad
;; License: MIT
;; Author: James Cherti
(evil-define-motion my-evil-ex-search-forward (count)
"Start a forward search without jumping to the next item."
:jump t
:type exclusive
:repeat evil-repeat-ex-search
@jamescherti
jamescherti / reload-theme.el
Created July 8, 2024 18:02
Emacs: Reload the currently active theme to reset all faces.
;; Description: Reload the currently active theme to reset all faces.
;; Gits URL: https://gist.github.com/jamescherti/202cd241e31af226c5b6d772a0d754e8
;; License: MIT
;; Author: James Cherti
(defun my-reload-theme ()
"Reload the currently active theme to reset all faces."
(interactive)
(let ((current-theme (car custom-enabled-themes)))
(when current-theme
@jamescherti
jamescherti / reset-face-attributes.el
Created July 8, 2024 17:31
Emacs: Set all attributes of the specified FACE to `unspecified'.
;; Description: Set all attributes of the specified FACE to `unspecified'.
;; Gits URL: https://gist.github.com/jamescherti/316e2f87b9e8f0af9a560ee594552083
;; License: MIT
;; Author: James Cherti
(defun my-reset-face-attributes (face)
"Set all attributes of the specified FACE to `unspecified'."
(when (facep face)
(let ((attributes (face-all-attributes face)))
(dolist (attr attributes)
@jamescherti
jamescherti / close-tab-move-next.el
Last active July 5, 2024 12:31
Emacs: Move to the next tab when the current tab is closed. (similar to Firefox.)
;; Description: Emacs: Move to the next tab when the current tab
;; is closed. (similar to Firefox.)
;; Gits URL: https://gist.github.com/jamescherti/21436157fa3764022c95f00dfe2ae828
;; License: MIT
;; Author: James Cherti
(defun my-tab-bar-close-tab-advice (orig-fun &rest args)
"Advice around `tab-bar-close-tab' to move to the next tab when closed.
ORIG-FUN is the original `tab-bar-close-tab` function. ARGS are the arguments
passed to `tab-bar-close-tab`."
@jamescherti
jamescherti / suppress-some-eglot-messages.el
Last active June 5, 2024 21:30
Suppress Eglot messages: Connected, Waiting, Reconnected
;; Gits URL: https://gist.github.com/jamescherti/cc0b0734f4f2e90e3854f7550054760b
;; License: MIT
;; Author: James Cherti
;;
;; Description:
;; ------------
;; This code provides an Emacs Lisp function to suppress specific Eglot
;; messages from being shown in the minibuffer.
(defun my-suppress-eglot-message (orig-fun format &rest args)