GNU bug report logs -
#45068
[PATCH] 28.0.50; Update Modus themes 1.0.2 (backward-incompatible)
Previous Next
Reported by: Protesilaos Stavrou <info <at> protesilaos.com>
Date: Sun, 6 Dec 2020 12:25:02 UTC
Severity: normal
Tags: patch
Fixed in version 28.1
Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 2021-03-06, 18:25 +0000, Gregory Heytings <gregory <at> heytings.org> wrote:
>>
>> It works. Thank you!
>>
>
> You are welcome :-) Actually the previous version had a bug with
> tab-indented lines. It is fixed now:
>
> (defun undercaret (&optional arg)
> (interactive "p")
> (let* ((begin (if (region-active-p) (region-beginning) (line-beginning-position)))
> (end (if (region-active-p) (region-end) (line-end-position)))
> (lines (- (line-number-at-pos end) (line-number-at-pos begin) -1))
> (comment (and (/= arg 1) (= lines 1)))
> (final-forward-line -1))
> (goto-char begin)
> (dotimes (i lines)
> (let* ((line-begin (if (zerop i) begin (line-beginning-position)))
> (line-end (if (= (1+ i) lines) end (line-end-position)))
> (begin-column (progn (goto-char line-begin) (current-column)))
> (end-column (progn (goto-char line-end) (current-column)))
> (prefix-begin (line-beginning-position))
> (prefix-end (progn (beginning-of-line-text) (point)))
> (prefix-end-column (progn (goto-char prefix-end) (current-column)))
> (delta (if (< begin-column prefix-end-column) (- prefix-end-column begin-column) 0))
> (prefix-string (buffer-substring-no-properties prefix-begin prefix-end))
> (prefix (if (string-match-p "\\` *\\'" prefix-string) "" prefix-string))
> (whitespace (make-string (- (+ begin-column delta) (string-width prefix)) ?\ ))
> (do-under (< delta (- line-end line-begin)))
> (under (if do-under (make-string (- end-column begin-column delta) ?^) ""))
> (under-string (concat prefix whitespace under "\n")))
> (forward-line 1)
> (if do-under (insert under-string) (setq final-forward-line -2))
> (setq end (+ end (length under-string)))
> (when comment (insert prefix whitespace "\n"))))
> (forward-line final-forward-line)
> (goto-char (line-end-position))))
I admit not to have tested it thoroughly (not yet, anyway). Though I do
plan to use your function. Thanks!
I will eventually include it in my public dotfiles' repo. Is there a
link I could provide as a reference to your contribution? Or just cite
the message in this thread?[1]
[1]: <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45068#250>.
> (BTW, sorry for the off-topic noise on your thread on modus-themes, but
> it was you who asked for a solution ;-))
Yes, I guess this is not the right place to discuss this feature...
Though the bug has been closed successfully.
I had asked because I was under the impression that Gnus or some other
library was implementing it.
--
Protesilaos Stavrou
protesilaos.com
This bug report was last modified 4 years and 135 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.