Skip to content

Instantly share code, notes, and snippets.

View jamescherti's full-sized avatar

James Cherti jamescherti

View GitHub Profile
@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)
;; Gits URL: https://gist.github.com/jamescherti/095812fefed49894cde5e5945ce5d63a
;; License: MIT
;; Author: James Cherti
;;
;; Description:
;; ------------
;; Make the built-in (save-some-buffers) function automatically save
;; buffers that are visiting existing files, without prompting the
;; user for confirmation.
;; URL: https://gist.github.com/jamescherti/d4179eeece026081ac5d10d9eb1b25cf
;; License: MIT
;; Author: James Cherti
;;
;; Description:
;; Preserving Info-history-list across sessions using savehist or desktop.el
;; allows users to save and restore the links marked as "read" within the Info
;; system, providing a visual cue of which nodes have been visited.
;;
;; Info-history-list in Emacs is a variable that stores a list of previously
@jamescherti
jamescherti / fix-electric-pair-C-h.el
Last active May 26, 2024 13:34
Fix Electric Pair delete adjacent pair when C-h is pressed
;; Gits URL: https://gist.github.com/jamescherti/8a7c6e926fcb6a16251bc24b1fe06bcf
;; License: MIT
;; Author: James Cherti
;;
;; Description:
;; ------------
;; When the C-h key is pressed in Emacs Evil mode, and
;; electric-pair-delete-adjacent-pairs is set to true, Electric Pair should
;; delete an adjacent pair of characters, similar to the behavior of the
;; Backspace key. Currently, this functionality only works with the Backspace
@jamescherti
jamescherti / .wcalcrc
Created May 21, 2024 18:20
wcalc configuration file ~/.wcalcrc
# Description: wcalc configuration file ~/.wcalcrc
# Gits URL: https://gist.github.com/jamescherti/ca94710ab7b473ca2e5118519fb06672
# License: MIT
# Author: James Cherti
precision=2
show_equals=false
save_errors=true
history_limit=2000
color=true
@jamescherti
jamescherti / switch-project-find-file.el
Last active May 3, 2024 15:13
Emacs: Switch to another project using (find-file)
;; Description:
;; Emacs: Switch to another project using (find-file)
;; Gits URL: https://gist.github.com/jamescherti/bf74fb911d17583e7f4b57946f1ea775
;; License: MIT
;; Author: James Cherti
(defun my-project-prompt-project-dir ()
"Prompt the user for a directory that is one of the known project roots."
(project--ensure-read-project-list)
(setq pr-dir (completing-read "Select project: " project--list nil t)))
;; Description:
;; Prevent 'evil-paste-after' and 'evil-paste-before' from failing when the
;; paste ring (akin to the clipboard) is empty.
;;
;; Gits URL:
;; License: MIT
;; Author: James Cherti
(defun ignore-empty-ring-errors (orig-func &rest args)
"Ignore errors related to the empty ring when calling ORIG-FUNC with ARGS."