Skip to content

Instantly share code, notes, and snippets.

View jamescherti's full-sized avatar

James Cherti jamescherti

View GitHub Profile
@jamescherti
jamescherti / describe-elisp-symbol-at-point.el
Last active September 17, 2024 12:32
;;; my-describe-symbol-at-point.el --- Describe variable or function at point -*- lexical-binding: t; -*-
;;; describe-symbol-at-point.el --- Describe variable or function at point -*- lexical-binding: t; -*-
;; Description: Clear the contents of the *Messages* buffer if it is the current buffer.
;; Gits URL: https://gist.github.com/jamescherti/abb288cb98f5f9f08431cc29225273fe
;; License: MIT
;; Author: James Cherti
(defun my-describe-elisp-symbol-at-point ()
"Describe the symbol at point as either a variable or a function.
This function determines whether the symbol at point is a variable or a
@jamescherti
jamescherti / clear-messages-buffer.el
Last active August 23, 2024 22:08
Emacs: Clear the contents of the *Messages* buffer if it is the current buffer
;; Description: Clear the contents of the *Messages* buffer if it is the current buffer.
;; Gits URL: https://gist.github.com/jamescherti/52e8fe8700ab394163bb99f2b8d456fd
;; License: MIT
;; Author: James Cherti
(defun my-clear-messages-buffer ()
"Clear the contents of the *Messages* buffer if it is the current buffer."
(when (string= (buffer-name) "*Messages*")
(let ((was-read-only buffer-read-only))
(when was-read-only
@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)