Last active
January 19, 2023 01:20
-
-
Save no-defun-allowed/34b097954cc5af6f80abbd2f7fa94f77 to your computer and use it in GitHub Desktop.
Revisions
-
no-defun-allowed revised this gist
Jan 19, 2023 . No changes.There are no files selected for viewing
-
no-defun-allowed revised this gist
Apr 14, 2022 . No changes.There are no files selected for viewing
-
no-defun-allowed revised this gist
Mar 25, 2022 . 1 changed file with 1 addition and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,11 +47,5 @@ lines))) (defun variable-pitch-hook-handler (s e l) (variable-pitch-indent)) (push 'variable-pitch-hook-handler after-change-functions) -
no-defun-allowed revised this gist
Mar 23, 2022 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,8 @@ (save-excursion (let ((spine "") (face `(:foreground ,(face-attribute 'default :background nil))) (needs-full? (not *vpi-did-full-indent?*)) (lines 0)) ;; Start early if we know the rest of the buffer is okay. Note ;; that we won't propagate anything beyond lines with no ;; indentation. @@ -24,8 +25,8 @@ (while (not (eobp)) (back-to-indentation) ;; Get out early if we know the rest of the buffer is okay. (when (and (not needs-full?) (zerop (current-column)) (plusp lines)) (return-from variable-pitch-indent lines)) (unless (eolp) (let* ((indentation-amount (current-column)) (spine-cut (min (length spine) indentation-amount)) @@ -40,8 +41,10 @@ (put-text-property (point-at-bol) (point) 'display (propertize (concat spine-prefix spine-padding) 'face face)))) (forward-line 1) (incf lines)) (when needs-full? (setf *vpi-did-full-indent?* t)) lines))) (defun variable-pitch-hook-handler (s e l) (when (member this-command '(self-insert-command -
no-defun-allowed created this gist
Mar 22, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ ;; A grown up version of https://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00127.html (defvar-local *vpi-did-full-indent?* nil) (defun vpi-find-start () (loop (back-to-indentation) (when (or (= (point-min) (point)) (zerop (current-column))) (return)) (forward-line -1))) (cl-defun variable-pitch-indent () (interactive) (save-excursion (let ((spine "") (face `(:foreground ,(face-attribute 'default :background nil))) (needs-full? (not *vpi-did-full-indent?*))) ;; Start early if we know the rest of the buffer is okay. Note ;; that we won't propagate anything beyond lines with no ;; indentation. (if needs-full? (goto-char (point-min)) (vpi-find-start)) (while (not (eobp)) (back-to-indentation) ;; Get out early if we know the rest of the buffer is okay. (when (and (not needs-full?) (zerop (current-column))) (return-from variable-pitch-indent)) (unless (eolp) (let* ((indentation-amount (current-column)) (spine-cut (min (length spine) indentation-amount)) (spine-prefix (substring spine 0 spine-cut)) (spine-padding (make-string (- indentation-amount spine-cut) ?\s)) (spine-end (buffer-substring (point) (point-at-eol)))) (setq spine (with-temp-buffer (insert spine-prefix spine-padding spine-end) (untabify (point-min) (point-max)) (buffer-string))) (put-text-property (point-at-bol) (point) 'display (propertize (concat spine-prefix spine-padding) 'face face)))) (forward-line 1)) (when needs-full? (setf *vpi-did-full-indent?* t))))) (defun variable-pitch-hook-handler (s e l) (when (member this-command '(self-insert-command newline slime-autodoc-space indent-for-tab-command backward-delete-char-untabify yank)) (variable-pitch-indent))) (push 'variable-pitch-hook-handler after-change-functions)