Reorganize and shit
- paredit -> smartparens - re-builder (C-M-5) - other stuff - reorder
This commit is contained in:
parent
437f92c71c
commit
4c1475e739
171
init.el
171
init.el
|
@ -317,19 +317,6 @@
|
|||
"C-c C-k" #'acdw/eval-region-or-buffer
|
||||
"C-c C-z" #'ielm)))
|
||||
|
||||
(setup pulse
|
||||
(:option pulse-flag nil)
|
||||
|
||||
(defun pulse-line (&rest _)
|
||||
"Pulse the current line."
|
||||
(pulse-momentary-highlight-one-line (point)))
|
||||
|
||||
(dolist (command '(scroll-up-command
|
||||
scroll-down-command
|
||||
recenter-top-bottom other-window
|
||||
switch-to-buffer))
|
||||
(advice-add command :after #'pulse-line)))
|
||||
|
||||
(setup emacs
|
||||
;; "Et cetera" settings
|
||||
;; This should stay as /minimal/ as possible. Anything that can go somewhere
|
||||
|
@ -365,6 +352,7 @@
|
|||
(global-set-key (kbd "C-c l") lookup-map)
|
||||
|
||||
(:global "M-=" #'count-words
|
||||
"C-M-;" #'comment-or-uncomment-sexp
|
||||
"C-w" #'kill-region-or-backward-word
|
||||
"C-c d" #'acdw/insert-iso-date
|
||||
"M-`" nil
|
||||
|
@ -734,14 +722,40 @@ specific to most general, they are these:
|
|||
show-paren-when-point-in-periphery t
|
||||
smie-indent-basic tab-width)
|
||||
|
||||
(:hook show-paren-mode
|
||||
electric-pair-local-mode
|
||||
acdw/setup-fringes
|
||||
(:hook #'show-paren-mode
|
||||
#'electric-pair-local-mode
|
||||
#'acdw/setup-fringes
|
||||
#'display-fill-column-indicator-mode
|
||||
|
||||
(defun prog-mode@auto-fill ()
|
||||
(setq-local comment-auto-fill-only-comments t)
|
||||
(turn-on-auto-fill))))
|
||||
|
||||
(setup pulse
|
||||
(:option pulse-flag t
|
||||
pulse-delay 0.5
|
||||
pulse-iterations 1)
|
||||
|
||||
(defun pulse-line (&rest _)
|
||||
"Pulse the current line."
|
||||
(pulse-momentary-highlight-one-line (point)))
|
||||
|
||||
(dolist (command '(scroll-up-command
|
||||
scroll-down-command
|
||||
recenter-top-bottom other-window
|
||||
switch-to-buffer))
|
||||
(advice-add command :after #'pulse-line)))
|
||||
|
||||
(setup re-builder
|
||||
(require 'acdw-re)
|
||||
(:global "C-M-5" #'re-builder
|
||||
"C-M-%" #'re-builder)
|
||||
(:with-map reb-mode-map
|
||||
(:bind "C-c C-k" #'reb-quit
|
||||
"RET" #'reb-replace-regexp))
|
||||
(:with-map reb-lisp-mode-map
|
||||
(:bind "RET" #'reb-replace-regexp)))
|
||||
|
||||
(setup repeat
|
||||
;; new for Emacs 28!
|
||||
(:only-if (fboundp #'repeat-mode))
|
||||
|
@ -1091,11 +1105,13 @@ specific to most general, they are these:
|
|||
lui-track-behavior 'before-switch-to-buffer
|
||||
lui-track-indicator 'fringe
|
||||
lui-fill-remove-face-from-newline nil)
|
||||
|
||||
|
||||
(:hook #'visual-fill-column-mode
|
||||
#'visual-line-mode)
|
||||
|
||||
(:local-set fringes-outside-margins t
|
||||
(:local-set visual-fill-column-extra-text-width (cons acdw-irc/left-margin
|
||||
0)
|
||||
fringes-outside-margins t
|
||||
right-margin-width 5
|
||||
scroll-margin 0
|
||||
word-wrap t
|
||||
|
@ -1207,8 +1223,8 @@ specific to most general, they are these:
|
|||
(crux-reopen-as-root-mode +1))
|
||||
|
||||
(setup (:straight-if (define-repeat-map
|
||||
:host nil
|
||||
:repo "https://tildegit.org/acdw/define-repeat-map.el")
|
||||
:host nil
|
||||
:repo "https://tildegit.org/acdw/define-repeat-map.el")
|
||||
(acdw/system :home))
|
||||
|
||||
(require 'define-repeat-map ; just for me
|
||||
|
@ -1732,7 +1748,7 @@ browser defined in `browse-url-secondary-browser-function'."
|
|||
modus-themes-bold-constructs t
|
||||
modus-themes-fringes nil
|
||||
modus-themes-mode-line '(borderless moody)
|
||||
modus-themes-region '(bg-only no-extend)
|
||||
modus-themes-region '(bg-only)
|
||||
modus-themes-org-blocks 'gray-background
|
||||
modus-themes-headings '((t . (background)))
|
||||
modus-themes-lang-checkers '(straight-underline)
|
||||
|
@ -1744,27 +1760,27 @@ browser defined in `browse-url-secondary-browser-function'."
|
|||
(add-hook 'modus-themes-after-load-theme-hook
|
||||
(defun modus-themes@customize-faces ()
|
||||
"Customize faces of modus-themes."
|
||||
(dolist (face '(font-lock-builtin-face
|
||||
;; font-lock-comment-delimiter-face
|
||||
;; font-lock-coment-face
|
||||
font-lock-constant-face
|
||||
;; font-lock-doc-face
|
||||
font-lock-function-name-face
|
||||
font-lock-keyword-face
|
||||
font-lock-negation-char-face
|
||||
font-lock-preprocessor-face
|
||||
font-lock-regexp-grouping-backslash
|
||||
font-lock-regexp-goruping-construct
|
||||
font-lock-string-face
|
||||
font-lock-type-face
|
||||
font-lock-variable-name-face
|
||||
font-lock-warning-face))
|
||||
(modus-themes-with-colors
|
||||
(custom-set-faces
|
||||
`(,face
|
||||
((,class :foreground ,fg-main
|
||||
:weight normal
|
||||
:slant normal))))))
|
||||
;; (dolist (face '(font-lock-builtin-face
|
||||
;; ;; font-lock-comment-delimiter-face
|
||||
;; ;; font-lock-coment-face
|
||||
;; font-lock-constant-face
|
||||
;; ;; font-lock-doc-face
|
||||
;; font-lock-function-name-face
|
||||
;; font-lock-keyword-face
|
||||
;; font-lock-negation-char-face
|
||||
;; font-lock-preprocessor-face
|
||||
;; font-lock-regexp-grouping-backslash
|
||||
;; font-lock-regexp-goruping-construct
|
||||
;; font-lock-string-face
|
||||
;; font-lock-type-face
|
||||
;; font-lock-variable-name-face
|
||||
;; font-lock-warning-face))
|
||||
;; (modus-themes-with-colors
|
||||
;; (custom-set-faces
|
||||
;; `(,face
|
||||
;; ((,class :foreground ,fg-main
|
||||
;; :weight normal
|
||||
;; :slant normal))))))
|
||||
;; Other faces
|
||||
(modus-themes-with-colors
|
||||
(custom-set-faces
|
||||
|
@ -1801,15 +1817,15 @@ browser defined in `browse-url-secondary-browser-function'."
|
|||
(:option nov-text-width fill-column)
|
||||
(:file-match (rx ".epub" eos)))
|
||||
|
||||
(setup (:straight olivetti)
|
||||
(:option olivetti-body-width (+ fill-column 4)
|
||||
olivetti-minimum-body-width fill-column)
|
||||
|
||||
(:hook (defun olivetti-mode@setup ()
|
||||
(if olivetti-mode
|
||||
(setq-local indicate-empty-lines nil
|
||||
indicate-buffer-boundaries nil)
|
||||
(acdw/setup-fringes)))))
|
||||
;; (setup (:straight olivetti)
|
||||
;; (:option olivetti-body-width (+ fill-column 4)
|
||||
;; olivetti-minimum-body-width fill-column)
|
||||
|
||||
;; (:hook (defun olivetti-mode@setup ()
|
||||
;; (if olivetti-mode
|
||||
;; (setq-local indicate-empty-lines nil
|
||||
;; indicate-buffer-boundaries nil)
|
||||
;; (acdw/setup-fringes)))))
|
||||
|
||||
(setup (:straight (orderless
|
||||
:host github
|
||||
|
@ -2055,32 +2071,30 @@ the default is \"/\"."
|
|||
(setup (:straight org-sticky-header)
|
||||
(:hook-into org-mode))
|
||||
|
||||
(setup (:straight package-lint))
|
||||
|
||||
(setup (:straight package-lint-flymake))
|
||||
(setup (:straight package-lint
|
||||
package-lint-flymake))
|
||||
|
||||
(setup (:straight page-break-lines)
|
||||
(global-page-break-lines-mode +1))
|
||||
|
||||
(setup (:straight paredit)
|
||||
(:bind "DEL" #'paredit-backward-delete
|
||||
"C-M-;" #'comment-or-uncomment-sexp
|
||||
"C-<backspace>" #'paredit-backward-kill-word
|
||||
"M-w" #'paredit-copy-as-kill
|
||||
"RET" #'paredit-newline)
|
||||
;; (setup (:straight paredit)
|
||||
;; (:bind "DEL" #'paredit-backward-delete
|
||||
;; "C-<backspace>" #'paredit-backward-kill-word
|
||||
;; "M-w" #'paredit-copy-as-kill
|
||||
;; "RET" #'paredit-newline)
|
||||
|
||||
(:unbind "M-s" ; paredit-splice-sexp
|
||||
"C-j" ; paredit-newline (rebound to RET)
|
||||
)
|
||||
;; (:unbind "M-s" ; paredit-splice-sexp
|
||||
;; "C-j" ; paredit-newline (rebound to RET)
|
||||
;; )
|
||||
|
||||
(:hook-into emacs-lisp-mode
|
||||
ielm-mode sly-repl-mode
|
||||
lisp-mode
|
||||
lisp-interaction-mode
|
||||
scheme-mode)
|
||||
|
||||
(:also-load eldoc)
|
||||
(eldoc-add-command 'paredit-backward-delete 'paredit-close-round))
|
||||
;; (:hook-into emacs-lisp-mode
|
||||
;; ielm-mode sly-repl-mode
|
||||
;; lisp-mode
|
||||
;; lisp-interaction-mode
|
||||
;; scheme-mode)
|
||||
|
||||
;; (:also-load eldoc)
|
||||
;; (eldoc-add-command 'paredit-backward-delete 'paredit-close-round))
|
||||
|
||||
(setup (:straight paren-face)
|
||||
(:hook-into emacs-lisp-mode
|
||||
|
@ -2206,6 +2220,10 @@ the default is \"/\"."
|
|||
|
||||
(:bind "C-c C-c" #'sly-mrepl-return)))
|
||||
|
||||
(setup (:straight smartparens)
|
||||
(require 'smartparens-config)
|
||||
(add-hook 'prog-mode #'smartparens-strict-mode))
|
||||
|
||||
(setup (:straight ssh-config-mode)
|
||||
(:file-match (rx "/.ssh/config" eos)
|
||||
(rx "/ssh" (? "d") "_config" eos))
|
||||
|
@ -2232,7 +2250,16 @@ the default is \"/\"."
|
|||
(setup (:straight (topsy
|
||||
:host github
|
||||
:repo "alphapapa/topsy.el"))
|
||||
(:hook-into prog-mode))
|
||||
(:hook-into prog-mode)
|
||||
(:when-loaded
|
||||
(:option topsy-header-line-format
|
||||
'(:eval
|
||||
(list
|
||||
(propertize " "
|
||||
'display
|
||||
'((space :align-to
|
||||
,(unless visual-fill-column-mode 0))))
|
||||
(funcall topsy-fn))))))
|
||||
|
||||
(setup (:straight trashed)
|
||||
(:option trashed-action-confirmer #'y-or-n-p))
|
||||
|
|
109
lisp/acdw-re.el
109
lisp/acdw-re.el
|
@ -23,21 +23,22 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(defvar acdw/re-builder-positions nil
|
||||
"Store point and region bounds before calling re-builder")
|
||||
(require 're-builder)
|
||||
|
||||
(defun acdw/re-builder-save-state (&rest _)
|
||||
"Save into `acdw/re-builder-positions' the point and region
|
||||
positions before calling `re-builder'."
|
||||
(setq acdw/re-builder-positions
|
||||
(defvar my/re-builder-positions nil
|
||||
"Store point and region bounds before calling `re-builder'.")
|
||||
|
||||
(defun my/re-builder-save-state (&rest _)
|
||||
"Save the point and region before calling `re-builder'."
|
||||
(setq my/re-builder-positions
|
||||
(cons (point)
|
||||
(when (region-active-p)
|
||||
(list (region-beginning)
|
||||
(region-end))))))
|
||||
|
||||
(defun reb-replace-regexp (&optional delimited)
|
||||
"Run `query-replace-regexp' with the contents of re-builder. With
|
||||
non-nil optional argument DELIMITED, only replace matches
|
||||
"Run `query-replace-regexp' with the contents of `re-builder'.
|
||||
With non-nil optional argument DELIMITED, only replace matches
|
||||
surrounded by word boundaries."
|
||||
(interactive "P")
|
||||
(reb-update-regexp)
|
||||
|
@ -56,17 +57,95 @@ surrounded by word boundaries."
|
|||
" in region"
|
||||
""))
|
||||
t))
|
||||
(pnt (car acdw/re-builder-positions))
|
||||
(beg (cadr acdw/re-builder-positions))
|
||||
(end (caddr acdw/re-builder-positions)))
|
||||
(pnt (car my/re-builder-positions))
|
||||
(beg (cadr my/re-builder-positions))
|
||||
(end (caddr my/re-builder-positions)))
|
||||
(with-selected-window reb-target-window
|
||||
;; replace with (goto-char (match-beginning 0)) if you want to control
|
||||
;; where in the buffer the replacement starts with re-builder
|
||||
(goto-char pnt)
|
||||
(setq acdw/re-builder-positions nil)
|
||||
(goto-char (or pnt 0))
|
||||
(setq my/re-builder-positions nil)
|
||||
(reb-quit)
|
||||
(query-replace-regexp re replacement delimited beg end))))
|
||||
|
||||
;; Restrict re-builder matches to region
|
||||
|
||||
(defun reb-update-overlays (&optional subexp)
|
||||
"Switch to `reb-target-buffer' and mark all matches of `reb-regexp'.
|
||||
If SUBEXP is non-nil mark only the corresponding sub-expressions."
|
||||
(let* ((re (reb-target-binding reb-regexp))
|
||||
(subexps (reb-count-subexps re))
|
||||
(matches 0)
|
||||
(submatches 0)
|
||||
firstmatch
|
||||
here
|
||||
start end
|
||||
firstmatch-after-here)
|
||||
(with-current-buffer reb-target-buffer
|
||||
(setq here
|
||||
(if reb-target-window
|
||||
(with-selected-window reb-target-window (window-point))
|
||||
(point))
|
||||
start
|
||||
(if (region-active-p)
|
||||
(nth 1 my/re-builder-positions)
|
||||
(nth 0 my/re-builder-positions))
|
||||
end
|
||||
(if (region-active-p)
|
||||
(nth 2 my/re-builder-positions)
|
||||
(point-max)))
|
||||
(reb-delete-overlays)
|
||||
(goto-char (or start 0))
|
||||
(while (and (not (eobp))
|
||||
(re-search-forward re end t)
|
||||
(or (not reb-auto-match-limit)
|
||||
(< matches reb-auto-match-limit)))
|
||||
(when (and (= 0 (length (match-string 0)))
|
||||
(not (eobp)))
|
||||
(forward-char 1))
|
||||
(let ((i 0)
|
||||
suffix max-suffix)
|
||||
(setq matches (1+ matches))
|
||||
(while (<= i subexps)
|
||||
(when (and (or (not subexp) (= subexp i))
|
||||
(match-beginning i))
|
||||
(let ((overlay (make-overlay (match-beginning i)
|
||||
(match-end i)))
|
||||
;; When we have exceeded the number of provided faces,
|
||||
;; cycle thru them where `max-suffix' denotes the maximum
|
||||
;; suffix for `reb-match-*' that has been defined and
|
||||
;; `suffix' the suffix calculated for the current match.
|
||||
(face
|
||||
(cond
|
||||
(max-suffix
|
||||
(if (= suffix max-suffix)
|
||||
(setq suffix 1)
|
||||
(setq suffix (1+ suffix)))
|
||||
(intern-soft (format "reb-match-%d" suffix)))
|
||||
((intern-soft (format "reb-match-%d" i)))
|
||||
((setq max-suffix (1- i))
|
||||
(setq suffix 1)
|
||||
;; `reb-match-1' must exist.
|
||||
'reb-match-1))))
|
||||
(unless firstmatch (setq firstmatch (match-data)))
|
||||
(unless firstmatch-after-here
|
||||
(when (> (point) here)
|
||||
(setq firstmatch-after-here (match-data))))
|
||||
(setq reb-overlays (cons overlay reb-overlays)
|
||||
submatches (1+ submatches))
|
||||
(overlay-put overlay 'face face)
|
||||
(overlay-put overlay 'priority i)))
|
||||
(setq i (1+ i))))))
|
||||
(let ((count (if subexp submatches matches)))
|
||||
(message "%s %smatch%s%s"
|
||||
(if (= 0 count) "No" (int-to-string count))
|
||||
(if subexp "subexpression " "")
|
||||
(if (= 1 count) "" "es")
|
||||
(if (and reb-auto-match-limit
|
||||
(= reb-auto-match-limit count))
|
||||
" (limit reached)" "")))
|
||||
(when firstmatch
|
||||
(store-match-data (or firstmatch-after-here firstmatch))
|
||||
(reb-show-subexp (or subexp 0)))))
|
||||
|
||||
(provide 'acdw-re)
|
||||
|
||||
;;; acdw-re.el ends here
|
||||
|
|
Loading…
Reference in New Issue