From 90056b3191eddccee2954b36ee77137fdec5ce29 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 7 Oct 2021 16:00:39 -0500 Subject: Add require/ function --- lisp/acdw.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index cc73071..50ca00c 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -878,7 +878,23 @@ three blank lines, then place the point on the second one." (newline) (delete-blank-lines) (newline 2) - (previous-line)) + (forward-line -1)) + +(defun require/ (feature &optional filename noerror) + "If FEATURE is not loaded, load it from FILENAME. +This function works just like `require', with one crucial +difference: if the FEATURE name contains a slash, the FILENAME +will as well -- unless, of course, FILENAME is set. This allows +for `require/' to require files within subdirectories of +directories of `load-path'. Of course, NOERROR isn't affected by +the change." + (let* ((feature-name (if (symbolp feature) + (symbol-name feature) + feature)) + (filename (or filename + (and (string-match-p "/" feature-name) + feature-name)))) + (require (intern feature-name) filename noerror))) (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81 From 5e3f88cde60426a0497370a11d77fad8e3b5dd01 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 7 Oct 2021 17:28:51 -0500 Subject: Break spongebob-case to its own package --- init.el | 8 ++++++-- lisp/acdw.el | 26 -------------------------- 2 files changed, 6 insertions(+), 28 deletions(-) (limited to 'lisp/acdw.el') diff --git a/init.el b/init.el index ac88cde..efcf846 100644 --- a/init.el +++ b/init.el @@ -431,8 +431,7 @@ (:bind "c" #'capitalize-dwim "t" #'titlecase-dwim "u" #'upcase-dwim - "l" #'downcase-dwim - "s" #'spongebob-case-dwim)) + "l" #'downcase-dwim)) (column-number-mode +1)) @@ -2388,6 +2387,11 @@ the default is \"/\"." (:unbind "M-j" ; sp-join-sexp )) +(setup (:straight (spongebob-case + :host github + :repo "duckwork/spongebob-case.el")) + (:global "C-c c s" #'spongebob-case-dwim)) + (setup (:straight ssh-config-mode) (:file-match (rx "/.ssh/config" eos) (rx "/ssh" (? "d") "_config" eos)) diff --git a/lisp/acdw.el b/lisp/acdw.el index 50ca00c..489b808 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -793,32 +793,6 @@ This function is internal. Use `acdw/make-password-fetcher' instead." (insert "💩") (setq n (1- n))))) -(defun spongebob-case-region (beg end) - "Make region, defined by BEG and END, lOoK lIkE tHiS." - (interactive "*r") - (save-excursion - (let (case) - (goto-char beg) - (while (< (point) end) - (if (looking-at "[[:alpha:]]") - (if (setq case (not case)) - (upcase-region (point) (progn (forward-char 1) (point))) - (downcase-region (point) (progn (forward-char 1) (point)))) - (forward-char 1)))))) - -(defun spongebob-case-word (n) - "Spongebob-case N words forward, beginning at point, moving over." - (interactive "*p") - (spongebob-case-region (point) (progn (forward-word n) (point)))) - -(defun spongebob-case-dwim (arg) - "Spongebob-case words in the region if active, else word at point. -If ARG exists, it's passed to `spongebob-case-word'." - (interactive "*p") - (if (use-region-p) - (spongebob-case-region (region-beginning) (region-end)) - (spongebob-case-word arg))) - ;;; Fat finger solutions (defun acdw/fat-finger-exit (&optional prefix) -- cgit 1.4.1-21-gabe81