summaryrefslogtreecommitdiff
path: root/modules/custom-functions.el
diff options
context:
space:
mode:
authorCraig Jennings <craigmartinjennings@gmail.com>2024-04-11 17:29:10 -0500
committerCraig Jennings <craigmartinjennings@gmail.com>2024-04-11 17:29:10 -0500
commit43e1f37c02f216a36312876d56a8f313aabcf07a (patch)
treeea694f58737db225b5ac75beacb50a5d01515ad4 /modules/custom-functions.el
parent84c0963ec2096148932ec4ce8529a029cf930121 (diff)
additional bug fixing
- stray cj/bookmark-set-and-save references replaced with bookmark-set - added warning level for errors - added an alternate elpa-mirrors location (git repos shouldn't be added inside a git repo) - added default font size to "Berkeley Only" and the default in fontaine - updated eww to search using frog find for readability - fixed typo on comments in user-constants - moved easy hugo configuration higher for easier accessibility - move "insert around" function to custom functions
Diffstat (limited to 'modules/custom-functions.el')
-rw-r--r--modules/custom-functions.el51
1 files changed, 50 insertions, 1 deletions
diff --git a/modules/custom-functions.el b/modules/custom-functions.el
index 414d3108..345ebd08 100644
--- a/modules/custom-functions.el
+++ b/modules/custom-functions.el
@@ -238,7 +238,54 @@ User is prompted for the optional descriptor."
(unless (bolp) (insert "\n"))
(insert "```\n")
(goto-char start)
- (insert (concat "```" lang "\n")))))
+ (insert (concat "```" lang "\n")))))
+
+;; ------------------------ Insert Around Word Or Region -----------------------
+
+(defun cj/insert-around-word-or-region ()
+ "Prompt for a string, insert it before and after the word at point or selected region."
+ (interactive)
+ (let ((str (read-string "Enter a string: "))
+ (regionp (use-region-p)))
+ (save-excursion
+ (if regionp
+ (let ((beg (region-beginning))
+ (end (region-end)))
+ (goto-char end)
+ (insert str)
+ (goto-char beg)
+ (insert str))
+ (if (thing-at-point 'word)
+ (let ((bounds (bounds-of-thing-at-point 'word)))
+ (goto-char (cdr bounds))
+ (insert str)
+ (goto-char (car bounds))
+ (insert str))
+ (message "Can't insert around. No word at point and no region selected."))))))
+
+(global-set-key (kbd "C-; i a") 'cj/insert-around-word-or-region)
+;; ------------------------ Insert Around Word Or Region -----------------------
+
+(defun cj/insert-around-word-or-region ()
+ "Prompt for a string, insert it before and after the word at point or selected region."
+ (interactive)
+ (let ((str (read-string "Enter a string: "))
+ (regionp (use-region-p)))
+ (save-excursion
+ (if regionp
+ (let ((beg (region-beginning))
+ (end (region-end)))
+ (goto-char end)
+ (insert str)
+ (goto-char beg)
+ (insert str))
+ (if (thing-at-point 'word)
+ (let ((bounds (bounds-of-thing-at-point 'word)))
+ (goto-char (cdr bounds))
+ (insert str)
+ (goto-char (car bounds))
+ (insert str))
+ (message "Can't insert around. No word at point and no region selected."))))))
;; -------------------- Append To Lines In Region Or Buffer --------------------
;; append characters to the end of all lines in the region or the whole buffer.
@@ -536,6 +583,8 @@ Uses `sortable-time-format' for the formatting the date/time."
(global-set-key (kbd "C-; b m") 'cj/move-buffer-and-file)
;; copy link to source file
(global-set-key (kbd "C-; b l") 'cj/copy-link-to-source-file)
+;; insert around
+(global-set-key (kbd "C-; i a") 'cj/insert-around-word-or-region)
(provide 'custom-functions)
;;; custom-functions.el ends here.