Hi Tomas! On Fri, 8 Apr 2022 at 18:15, Tomas Hlavaty <[email protected]> wrote: > (...)
Let's imagine for a moment an `eepitch-preprocess-line' with lots of bells and whistles, and a person who is playing with her many definitions of `eepitch-preprocess-line' and experimenting with features that can be turned on and off. She has this in her ~/.emacs: ;; This block of code is also in: ;; http://angg.twu.net/elisp/eepitch-pl-tools.el.html ;; http://angg.twu.net/elisp/eepitch-pl-tools.el ;; (find-anggwget-elisp "elisp/eepitch-pl-tools.el") ;; Basic variants of `eepitch-preprocess-line'. ;; See: (find-eepitch-intro "3.3. `eepitch-preprocess-line'") (setq eepitch-preprocess-regexp "^#: ") (defun eepitch-preprocess-line-0 (line) line) (defun eepitch-preprocess-line-1 (line) (replace-regexp-in-string eepitch-preprocess-regexp "" line)) ;; Change `eepitch-preprocess-line'. ;; (find-eev "eepitch.el" "eepitch-this-line") ;; (find-eev "eepitch.el" "eepitch-this-line" "defun eepitch-preprocess-line") ;; Default when not experimenting with new features: same regexp everywhere. (defun eepitch-preprocess-line (line) (eepitch-preprocess-line-1 line)) ;; Some tools. ;; Tests: (eepitch-pl-get-line) ;; (eepitch-pl-flash 0 2) ;; (eepitch-pl-flash 2 10) ;; (eepitch-pl-flash-re "^;; ?") ;; (eepitch-pl-flash-re ";; ?") ;; (eepitch-pl-flash-re (rx alpha)) ;; (eepitch-pl-flash-re (rx digit)) ;; (defun eepitch-pl-flash (offset1 offset2 &optional face duration) "`ee-flash' the part of current line between OFFSET1 and OFFSET2." (ee-flash (+ (ee-bol) offset1) (+ (ee-bol) offset2) face duration)) (defun eepitch-pl-get-line () (buffer-substring-no-properties (ee-bol) (ee-eol))) (defun eepitch-pl-flash-re (re &optional subexp face duration) (let* ((line (eepitch-pl-get-line))) (when (string-match re line) (eepitch-pl-flash (match-beginning (or subexp 0)) (match-end (or subexp 0)) face duration)))) The function `eepitch-pl-flash', `eepitch-pl-get-line', and `eepitch-pl-flash-re' are tools that she thinks that are well-written enough, and that are used by some her experiments - that are scattered thought several files... and she is experimenting with: 1) highlighting the prefix that is ignored 2) variants of `eepitch-preprocess-line' that choose a different "prefix that is ignored" depending on the major mode 3) variants of `eepitch-preprocess-line' that replace things like "⟦password⟧" by other strings - and that highlight the replaced parts 4) variants with hacks to support rest-of-line comments in SmallTalk She needs simple ways to turn her experiments off when they break. And she thinks - and me too - that lines like these are good enough: (defun eepitch-preprocess-line (line) (eepitch-preprocess-line-0 line)) (defun eepitch-preprocess-line (line) (eepitch-preprocess-line-1 line)) (defun eepitch-preprocess-line (line) (eepitch-preprocess-line-2 line)) ...and that is more or less why I prefer to keep this as the default definition for `eepitch-preprocess-line' in eepitch.el: (defun eepitch-preprocess-line (line) line) I don't have any idea of how to write an `eepitch-preprocess-line' that is "general enough", and right now I prefer to force people who use alternative definitions for it to redefine `eepitch-preprocess-line' themselves explicitly... Note that this > Even better would be, if eev automatically figured out buffer mode > specific single line comments and dealt with those automatically. I > don't know how to do this. and > Another issue I am facing is that my email client indents email > threads with spaces so I cannot run eepitch blocks directly from > emails with the default eepitch config. It would be great if that > worked without any custom user configuration. can both be handled by the idea (2) above... but I think that this > Even better would be, if eev automatically figured out buffer mode > specific single line comments and dealt with those automatically. I > don't know how to do this. is not a good idea _now_ - it would be great to have posts here in the mailing list showing code to make the "prefix that is ignored" depend on the major mode, but I prefer to keep the default `eepitch-preprocess-line' as a no-op... Cheers, Eduardo Ochs http://angg.twu.net/#eev http://angg.twu.net/#eev-blogposts
