Merge branch 'main' of github.com:duckwork/.emacs.d
This commit is contained in:
commit
bb5d048df6
84
init.el
84
init.el
|
@ -13,7 +13,9 @@
|
|||
;; Everyone is permitted to do whatever with this software, without
|
||||
;; limitation. This software comes without any warranty whatsoever,
|
||||
;; but with two pieces of advice:
|
||||
|
||||
;; - Be kind to yourself.
|
||||
|
||||
;; - Make good choices.
|
||||
|
||||
;;; Commentary:
|
||||
|
@ -94,6 +96,38 @@
|
|||
(expand-file-name-exists-p "pkg/" user-emacs-directory)))
|
||||
(normal-top-level-add-subdirs-to-load-path)))
|
||||
|
||||
(setup autoinsert
|
||||
(require 'acdw-autoinsert)
|
||||
(acdw/define-auto-insert '(:replace t)
|
||||
;; This is my custom auto-insert for elisp files.
|
||||
'("\\.el\\'" . "Emacs Lisp header (acdw)")
|
||||
'("Short description: " ";;; "
|
||||
(file-name-nondirectory (buffer-file-name))
|
||||
" --- " str
|
||||
(make-string (max 2 ( - 80 (current-column) 27)) 32)
|
||||
"-*- lexical-binding: t; -*-"
|
||||
'(setq lexical-binding t)
|
||||
"\n\n;; Copyright (C) " (format-time-string "%Y")
|
||||
" " (getenv "ORGANIZATION") | (progn user-full-name)
|
||||
"\n\n;; Author: " (user-full-name)
|
||||
'(if (search-backward "&" (line-beginning-position) t)
|
||||
(replace-match (capitalize (user-login-name)) t t))
|
||||
'(end-of-line 1)
|
||||
" <" (progn user-mail-address) ">"
|
||||
& -2
|
||||
"\n\n;;; License:"
|
||||
"\n\n;; Everyone is permitted to do whatever with this software, without"
|
||||
"\n;; limitation. This software comes without any warranty whatsoever,"
|
||||
"\n;; but with two pieces of advice:"
|
||||
"\n\n;; - Be kind to yourself."
|
||||
"\n\n;; - Make good choices."
|
||||
"\n\n;;; Commentary:"
|
||||
"\n\n;; " _
|
||||
"\n\n;;; Code:"
|
||||
"\n\n\n\n(provide '" (file-name-base (buffer-file-name)) ")"
|
||||
"\n;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n"))
|
||||
(auto-insert-mode +1))
|
||||
|
||||
(setup autorevert
|
||||
(:option global-auto-revert-non-file-buffers t
|
||||
auto-revert-verbose nil)
|
||||
|
@ -397,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))
|
||||
|
||||
|
@ -523,11 +556,10 @@
|
|||
|
||||
(defun list-string-match-p (string regexp-list)
|
||||
"Return t if at least one regex in RETGEXP-LIST matches STRING, else nil."
|
||||
(when string ; if STRING is nil, return nil.
|
||||
(catch 'found
|
||||
(dolist (regexp regexp-list)
|
||||
(when (string-match regexp string)
|
||||
(throw 'found t))))))
|
||||
;; FINE alphapapa ;P
|
||||
(seq-some (lambda (regexp)
|
||||
(string-match regexp string))
|
||||
regexp-list))
|
||||
|
||||
(defun flymake-unless ()
|
||||
"Turn on `flymake-mode', UNLESS it's inhibited.
|
||||
|
@ -1185,6 +1217,7 @@ specific to most general, they are these:
|
|||
scroll-margin 0
|
||||
word-wrap t
|
||||
wrap-prefix (repeat-string acdw-irc/left-margin " ")
|
||||
nyan-mode nil
|
||||
line-number-mode nil
|
||||
column-number-mode nil
|
||||
file-percentage-mode nil)
|
||||
|
@ -1298,6 +1331,23 @@ specific to most general, they are these:
|
|||
"C-M-\\" #'crux-cleanup-buffer-or-region
|
||||
"C-x 4 t" #'crux-transpose-windows)
|
||||
|
||||
(el-patch-feature crux)
|
||||
(with-eval-after-load 'crux
|
||||
(el-patch-defun crux-reopen-as-root ()
|
||||
"Find file as root if necessary.
|
||||
|
||||
Meant to be used as `find-file-hook'.
|
||||
See also `crux-reopen-as-root-mode'."
|
||||
(unless (or
|
||||
;; This helps fix for `nov-mode', and possibly others.
|
||||
(el-patch-add (null buffer-file-name))
|
||||
(tramp-tramp-file-p buffer-file-name)
|
||||
(equal major-mode 'dired-mode)
|
||||
(not (file-exists-p (file-name-directory buffer-file-name)))
|
||||
(file-writable-p buffer-file-name)
|
||||
(crux-file-owned-by-user-p buffer-file-name))
|
||||
(crux-find-alternate-file-as-root buffer-file-name))))
|
||||
|
||||
(crux-reopen-as-root-mode +1))
|
||||
|
||||
;; (setup (:straight-when
|
||||
|
@ -1906,7 +1956,13 @@ browser defined in `browse-url-secondary-browser-function'."
|
|||
(:option nyan-animate-nyancat nil
|
||||
nyan-bar-length 20
|
||||
nyan-minimum-window-width fill-column)
|
||||
(nyan-mode +1))
|
||||
(nyan-mode +1)
|
||||
(defun disable-nyan-mode ()
|
||||
"Disable `nyan-mode' in current buffer."
|
||||
(setq-local nyan-mode -1))
|
||||
(dolist (mode '(eshell-mode
|
||||
comint-mode))
|
||||
(add-hook mode #'disable-nyan-mode)))
|
||||
|
||||
;; (setup (:straight olivetti)
|
||||
;; (:option olivetti-body-width (+ fill-column 4)
|
||||
|
@ -1927,7 +1983,8 @@ browser defined in `browse-url-secondary-browser-function'."
|
|||
orderless-component-separator #'orderless-escapable-split-on-space
|
||||
orderless-matching-styles '(orderless-literal
|
||||
orderless-regexp
|
||||
orderless-flex)
|
||||
;; orderless-flex
|
||||
)
|
||||
orderless-style-dispatchers '(acdw/orderless-dispatch))
|
||||
|
||||
(:advise orderless-regexp :filter-args
|
||||
|
@ -2032,7 +2089,7 @@ browser defined in `browse-url-secondary-browser-function'."
|
|||
org-src-window-setup 'current-window
|
||||
org-startup-truncated nil
|
||||
org-startup-with-inline-images t
|
||||
org-tags-column (- fill-column))
|
||||
org-tags-column (- (- fill-column (length org-ellipsis))))
|
||||
|
||||
(:bind "RET" #'acdw-org/return-dwim
|
||||
"<S-return>" #'acdw-org/org-table-copy-down
|
||||
|
@ -2375,6 +2432,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))
|
||||
|
@ -2511,7 +2573,7 @@ If used with a numeric prefix argument N, N backticks will be inserted."
|
|||
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy))
|
||||
|
||||
(setup (:straight visual-fill-column)
|
||||
(:option visual-fill-column-width (+ fill-column 4)
|
||||
(:option visual-fill-column-width fill-column
|
||||
visual-fill-column-center-text t
|
||||
(append reading-modes) '(visual-fill-column-mode . +1))
|
||||
(:hook-into org-mode)
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
;;; acdw-autoinsert.el --- autoinsert.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2021 Case Duckworth
|
||||
|
||||
;; Author: Case Duckworth <acdw@acdw.ne
|
||||
|
||||
;;; License:
|
||||
|
||||
;; Everyone is permitted to do whatever with this software, without
|
||||
;; limitation. This software comes without any warranty whatsoever,
|
||||
;; but with two pieces of advice:
|
||||
|
||||
;; - Be kind to yourself.
|
||||
|
||||
;; - Make good choices.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; These are my bespoke changes to the `autoinsert' library.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'autoinsert)
|
||||
(require 'cl-lib)
|
||||
|
||||
(defun acdw/define-auto-insert (options condition action)
|
||||
"Associate CONDITION with ACTION in `auto-insert-alist'.
|
||||
This function differs from `define-auto-insert' in that it won't
|
||||
allow more than one duplicate entry in `auto-insert-alist'.
|
||||
|
||||
OPTIONS is a plist with three optional arguments:
|
||||
|
||||
- `:testfn' takes a function to test the given CONDITION against
|
||||
the already-existing ones in `auto-insert-alist'. It defaults
|
||||
to testing the cdr of CONDITION against the cdar of each entry
|
||||
in `auto-insert-alist'.
|
||||
|
||||
- `:replace', if non-nil, will replace the matching entry with
|
||||
the given one. Default: nil.
|
||||
|
||||
- `:after' is the third, optional argument to `define-auto-insert'."
|
||||
(declare (indent 1))
|
||||
(let ((testfn (or (plist-get options :testfn)
|
||||
(lambda (a b)
|
||||
(string= (cdr a) (cdar b)))))
|
||||
(replace (or (plist-get options :replace) nil))
|
||||
(after (or (plist-get options :after) nil)))
|
||||
(when replace
|
||||
(setq auto-insert-alist
|
||||
(assoc-delete-all condition auto-insert-alist testfn)))
|
||||
(unless (assoc (list condition) auto-insert-alist testfn)
|
||||
(define-auto-insert condition action after))))
|
||||
|
||||
(provide 'acdw-autoinsert)
|
||||
;;; acdw-autoinsert.el ends here
|
44
lisp/acdw.el
44
lisp/acdw.el
|
@ -787,32 +787,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)
|
||||
|
@ -872,7 +846,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
|
||||
|
|
Loading…
Reference in New Issue