This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; clone-indirect-buffer-current-window.el --- Create an indirect buffer and switch to it.. -*- lexical-binding: t; -*- | |
;; Gits URL: https://gist.github.com/jamescherti/686d8cb3d636614cefe76c6fc7b76e55 | |
;; License: MIT | |
;; Author: James Cherti | |
(defun my-clone-indirect-buffer-current-window (&optional newname norecord) | |
"Create an indirect buffer and switch to it. | |
Creates a new indirect buffer with the same content as the current buffer, | |
preserving point position, window start, and horizontal scroll position. The | |
original buffer remains unchanged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; disable-truncation-arrow.el --- Disable the truncation arrow. -*- lexical-binding: t; -*- | |
;; Gits URL: https://gist.github.com/jamescherti/45c7f70d316c5d707910cbd1fdb676cb | |
;; License: MIT | |
;; Author: James Cherti | |
(defun my-disable-fringe-truncation-arrow () | |
"Disable the truncation arrow." | |
(unless (boundp 'fringe-indicator-alist) | |
(error "The fringe-indicator-alist was not declared")) | |
(setq fringe-indicator-alist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; delete-before-cursor-except-asterisks.el --- Emacs Evil Org-mode: Delete everything before the cursor except the first '*' and space. -*- lexical-binding: t; -*- | |
;; Gits URL: https://gist.github.com/jamescherti/15168bb060d79a5c57215e62dd9bfa55 | |
;; License: MIT | |
;; Author: James Cherti | |
(with-eval-after-load "org" | |
(with-eval-after-load "evil" | |
(defun my-evil-delete-to-heading-star () | |
"Delete everything before the cursor except the first '*' and space. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; save-marker-and-window.el --- Emacs: Save point as a marker, window start/hscroll, restoring them after BODY. -*- lexical-binding: t; -*- | |
;; Gits URL: https://gist.github.com/jamescherti/8921b341b628599ca8c7ff7f173a435a | |
;; Usage: (my-save-marker-and-window (progn (your-code argument))) | |
;; License: MIT | |
;; Author: James Cherti | |
(defmacro my-save-marker-and-window (&rest body) | |
"Save point as a marker, window start/hscroll, restoring them after BODY." | |
`(let ((point-marker (copy-marker (point))) | |
(window-start-marker (copy-marker (window-start))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; shell-command-first-line-to-string.el --- Return the first line of output from executing COMMAND. -*- lexical-binding: t; -*- | |
;; Return the first line of output from executing COMMAND. | |
;; If the command fails or produces no output, return nil. | |
;; | |
;; This function is superior to `shell-command-to-string` because it allows | |
;; for the detection of command execution failures by examining the exit status. | |
;; While `shell-command-to-string` only returns the output as a string, | |
;; it does not provide information about whether the command succeeded or failed. | |
;; By using `call-process-shell-command`, this function can capture both | |
;; the output and the exit status, enabling better error handling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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)) |
NewerOlder