From c5b6a0774db7ecb2920db342abab5dbf5bcad9fb Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 14 Sep 2021 16:56:46 -0500 Subject: Add fat-finger-exit --- lisp/acdw.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw.el b/lisp/acdw.el index 91381da..b8a1906 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -632,6 +632,18 @@ This function is internal. Use `acdw/make-password-fetcher' instead." (interactive "p") (dotimes (or n 1) (insert "💩"))) + +;;; Fat finger solutions +(defun acdw/fat-finger-exit (&optional prefix) + "Delete a frame, or kill Emacs with confirmation. +When called with PREFIX, just kill Emacs without confirmation." + (interactive "P") + (if (or prefix + (and (= 1 (length (frame-list))) + (yes-or-no-p "This is the last frame! Wanna quit?"))) + (kill-emacs) + (ignore-errors + (delete-frame)))) (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81 From 4c9d8ea075657b1c35d3b7352043725b59525a82 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 14 Sep 2021 16:56:56 -0500 Subject: ~mehehheheh --- init.el | 69 +++++++++++++++++++++++++++------------------------ lisp/acdw-irc.el | 12 --------- lisp/acdw-modeline.el | 12 +++++++-- lisp/acdw.el | 33 ++++++++++++++++++------ 4 files changed, 72 insertions(+), 54 deletions(-) (limited to 'lisp') diff --git a/init.el b/init.el index ec5a825..4e558b8 100644 --- a/init.el +++ b/init.el @@ -934,8 +934,19 @@ AKA, DO NOT USE THIS FUNCTION!!!" (load (expand-file-name "eshell" user-emacs-directory)))))) (setup eww + (defvar-local eww-readable-p nil + "Whether current buffer is in readable-mode.") (:option eww-search-prefix "https://duckduckgo.com/html?q=" url-privacy-level '(email agent cookies lastloc)) + + (defun eww@is-readable (&rest _) + (setq-local eww-readable-p t)) + (defun eww@is-not-readable (&rest _) + (setq-local eww-readable-p nil)) + + (advice-add 'eww-readable :after #'eww@is-readable) + (advice-add 'eww-render :after #'eww@is-not-readable) + (advice-add 'eww-back-url :after #'eww@is-not-readable) (:hook #'reading-mode)) @@ -945,29 +956,7 @@ AKA, DO NOT USE THIS FUNCTION!!!" (exec-path-from-shell-initialize))) (setup (:straight expand-region) - (:global "C-=" #'er/expand-region - "C-SPC" - (defun acdw/set-mark-or-expand-region (arg) - "Set mark at point and activate, jump to mark, or expand region. -See `set-mark-command' and `expand-region'. - -With no prefix argument, either run `set-mark-command' on first -invocation and `er/expand-region' on each successive invocation. - -With any prefix argument -(e.g., \\[universal-argument] \\[set-mark-command]), act as with -`set-mark-command' (i.e., pop the mark). Don't care about -successive invocations." - (interactive "P") - (cond - ((or arg - (and set-mark-command-repeat-pop - (eq last-command 'pop-to-mark-command))) - (setq this-command 'set-mark-command) - (set-mark-command arg)) - ((eq last-command 'acdw/set-mark-or-expand-region) - (er/expand-region 1)) - (t (set-mark-command arg)))))) + (:global "C-=" #'er/expand-region)) (setup (:straight-if fennel-mode (executable-find "fennel")) @@ -1057,11 +1046,18 @@ specific to most general, they are these: (setup (:straight flyspell-correct) (:option flyspell-correct-interface #'flyspell-correct-completing-read - flyspell-correct--cr-key "`") + flyspell-correct--cr-key ";") + + (defun acdw/flyspell-correct-f7 () + "Run a full spell correction on the current buffer." + (interactive) + (save-mark-and-excursion + (flyspell-correct-move 0 :forward :rapid))) + (:with-feature flyspell - (:hook (defun flyspell@correct () - (:bind "C-;" #'flyspell-correct-wrapper) - (:unbind "C-," "C-." "C-M-i"))))) + (:bind "C-." #'flyspell-correct-wrapper + "" #'acdw/flyspell-correct-f7) + (:unbind "C-," "C-." "C-M-i"))) (setup (:straight-if forge (acdw/system :home)) @@ -1349,9 +1345,11 @@ browser defined in `browse-url-secondary-browser-function'." (setup (:straight markdown-mode) (:file-match (rx ".md" eos) (rx ".markdown" eos)) + (:hook #'variable-pitch-mode) (:with-mode gfm-mode - (:file-match (rx "README.md" eos))) + (:file-match (rx "README.md" eos)) + (:hook #'variable-pitch-mode)) (when (executable-find "markdownfmt") (with-eval-after-load 'apheleia @@ -1491,10 +1489,11 @@ browser defined in `browse-url-secondary-browser-function'." (:option org-adapt-indentation nil org-agenda-files nil ; only until I set this up - org-catch-invisible-edits 'smart + org-catch-invisible-edits 'show-and-error org-clock-clocked-in-display 'mode-line org-clock-string-limit 7 ; gives time and not title org-confirm-babel-evaluate nil + org-cycle-separator-lines 0 org-directory "~/org" org-ellipsis " …" org-export-coding-system 'utf-8-unix @@ -1510,6 +1509,9 @@ browser defined in `browse-url-secondary-browser-function'." org-html-coding-system 'utf-8-unix org-image-actual-width '(300) org-imenu-depth 3 + org-list-demote-modify-bullet '(("-" . "+") + ("+" . "*") + ("*" . "-")) org-outline-path-complete-in-steps nil org-pretty-entities t org-refile-use-outline-path 'file @@ -1614,7 +1616,7 @@ browser defined in `browse-url-secondary-browser-function'." (paredit-mode +1)) (dolist (mode lispy-modes) - (add-hook (intern (concat (symbol-name mode) "-hook")) + (add-hook (intern (format "%s-hook" mode)) #'paredit@setup)) (:also-load eldoc) @@ -1622,7 +1624,7 @@ browser defined in `browse-url-secondary-browser-function'." (setup (:straight paren-face) (dolist (mode lispy-modes) - (add-hook (intern (concat (symbol-name mode) "-hook")) #'paren-face-mode))) + (add-hook (intern (format "%s-hook" mode)) #'paren-face-mode))) (setup (:straight-if (pdf-tools :host github @@ -1652,8 +1654,8 @@ browser defined in `browse-url-secondary-browser-function'." (:global "C-c l t" #'powerthesaurus-lookup-word-dwim)) (setup (:straight prism) - (:hook-into lisp-mode - c-mode)) + (dolist (mode lispy-modes) + (add-hook (intern (format "%s-hook" mode)) #'prism-mode))) (setup prog (:option show-paren-delay 0 @@ -1824,6 +1826,7 @@ browser defined in `browse-url-secondary-browser-function'." simple-modeline-segment-process acdw-modeline/god-mode-indicator acdw-modeline/minions + acdw-modeline/reading-mode acdw-modeline/narrowed acdw-modeline/major-mode))) diff --git a/lisp/acdw-irc.el b/lisp/acdw-irc.el index 3755441..b4b75ec 100644 --- a/lisp/acdw-irc.el +++ b/lisp/acdw-irc.el @@ -45,18 +45,6 @@ Stolen from s.el." (setq num (1- num))) (apply 'concat ss)))) -(if (fboundp 's-truncate) - (defalias 'truncate-string 's-truncate) - (defun truncate-string (len s &optional ellipsis) - "If STR is longer than LEN, cut it down and add ELLIPSIS to the end. -When not specified, ELLIPSIS defaults to '...'." - (declare (pure t) (side-effect-free t)) - (unless ellipsis - (setq ellipsis "...")) - (if (> (length s) len) - (format "%s%s" (substring s 0 (- len (length ellipsis))) ellipsis) - s))) - ;;; IRC stuff diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 5aa0a18..6e5afb8 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -33,12 +33,16 @@ Otherwise, cdr should be a function that takes two points (see `count-words')." (defun acdw-modeline/buffer-name () ; gonsie "Display the buffer name in a face reflecting its modified status." - (propertize " %b " + (propertize (concat " " + (truncate-string (/ (window-total-width) 2) + (buffer-name) "~") + " ") 'face (if (buffer-modified-p) 'font-lock-warning-face 'font-lock-type-face) - 'help-echo (buffer-file-name))) + 'help-echo (or (buffer-file-name) + (buffer-name)))) (defun acdw-modeline/erc () "ERC indicator for the modeline." @@ -151,6 +155,10 @@ is, if point < mark." (region-bounds)))) 'font-lock-face 'font-lock-variable-name-face)))) +(defun acdw-modeline/reading-mode () + "Display an indicator if currently in reading mode, mine or EWW's." + (concat (if reading-mode "R" "") (if eww-readable-p "w" ""))) + (defun acdw-modeline/text-scale () "Display the text scaling from the modeline, if scaled." ;; adapted from https://github.com/seagle0128/doom-modeline diff --git a/lisp/acdw.el b/lisp/acdw.el index b8a1906..0790f2e 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -54,6 +54,16 @@ ARG). When called with multiple arguments or a list, it returns ;; I don't prefix these because ... reasons. Honestly I probably should prefix ;; them. +(defun truncate-string (len str &optional ellipsis) + "If STR is longer than LEN, cut it down and add ELLIPSIS to the end. +When not specified, ELLIPSIS defaults to '...'." + (declare (pure t) (side-effect-free t)) + (unless ellipsis + (setq ellipsis "...")) + (if (> (length str) len) + (format "%s%s" (substring str 0 (- len (length ellipsis))) ellipsis) + str)) + ;; Why isn't this a thing??? (defmacro fbound-and-true-p (func) "Return the value of function FUNC if it is bound, else nil." @@ -366,10 +376,15 @@ first." (goto-char (point-min)) (kill-line) (insert extracted-heading)) - (replace-regexp org-property-drawer-re "") ;Delete properties - (replace-regexp org-logbook-drawer-re "") ;Delete logbook + ;; Delete property drawers + (replace-regexp org-property-drawer-re "") + ;; Delete logbook drawers + (replace-regexp org-logbook-drawer-re "") + ;; Replace list items with their contents, paragraphed (replace-regexp org-list-full-item-re " \4") + ;; Delete comment lines + (replace-regexp (concat org-comment-regexp ".*$") "") ;; Re-fill text for clipboard (unfill-region (point-min) (point-max)) (flush-lines "^$" (point-min) (point-max))) @@ -626,12 +641,16 @@ This function is internal. Use `acdw/make-password-fetcher' instead." (setq-local blink-matching-paren nil show-paren-mode nil))) -;;; uh -(defun 💩 (n) - "💩 x N" + +;;; 💩 +(defun 💩 (&optional n) + "💩 x N." (interactive "p") - (dotimes (or n 1) - (insert "💩"))) + (let ((n (or n 1))) + (while (> n 0) + (insert "💩") + (setq n (1- n))))) + ;;; Fat finger solutions (defun acdw/fat-finger-exit (&optional prefix) -- cgit 1.4.1-21-gabe81