|
From: | Emanuel Berg |
Subject: | Re: Closures in Emacs and their usage scenarios. |
Date: | Tue, 28 Sep 2021 04:54:06 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (let ((alf-regexp)) > (defun align-from-left (&optional set-regexp) > (interactive "p") > (let ((default-regexp "^\\|[[:punct:]]\\|[[:space:]][[:alnum:]]")) > (unless (stringp set-regexp) > (cl-case set-regexp > ( 4 (setq alf-regexp (read-regexp "regexp: "))) > (16 (setq alf-regexp default-regexp)) > ( t (unless alf-regexp > (setq alf-regexp default-regexp) ))))) > (let ((beg (point)) > (re (or (and (stringp set-regexp) set-regexp) > alf-regexp) )) > (when (re-search-backward re (line-beginning-position) t) > (while (looking-at "[[:space:]]") > (forward-char 1) ) > (insert (make-string (- beg (point)) ?\s)) )))) Hm, looking at the code now I don't really understand what that regular expression "^\\|[[:punct:]]\\|[[:space:]][[:alnum:]]" is supposed to say ... but the program seems to work as intended. -- underground experts united https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |