help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[solved] Re: How to format paragraph and not to lose spaces between 2 ch


From: Jean Louis
Subject: [solved] Re: How to format paragraph and not to lose spaces between 2 characters?
Date: Wed, 6 Oct 2021 13:18:30 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

Thanks, I guess that easiest is to solve my use case and use
non-breaking space. I consider it solved, better this way then that I
fiddle with settings.

Org mode style is nice, though not enough visual for my purposes and
more or less it works only for numbered lines and headings.

,----
| 1. [X] A line of something, like a task for example.
`----

What I personally need is to mark TODO/DONE anywhere in the text in
any kind of mode, including Asciidoc mode, plain text and similar. And
to be able to mark TODO/DONE anywhere on the line. 

Like this, it has non-breaking spaces between: ❰    ❱ which may not be
visible on screen, but depending of the Emacs theme, I can see the
non-breaking space as underline:

,----
| ❰    ❱ A line of something, like a task for example.
`----

Then when it is done, I can quickly convert it to DONE.

,----
| ❰DONE❱ A line of something, like a task for example.
`----

And I use only one command: M-x rcd-check which is bound to key. One
could customize it as one wish, maybe like [✔]

Functions are below:

(defun rcd-check ()
  "Replace matches of CHECK-IN with CHECK-OUT in a line.

It is useful to toggle [ ] to [✔]"
  (interactive)
  (let* ((start (line-beginning-position))
         (end (line-end-position))
         (line (buffer-substring start end)))
    (rcd-check-start)
    (save-excursion
      (cond ((string-match (regexp-quote rcd-check-in) line) 
             (replace-regexp (regexp-quote rcd-check-in) rcd-check-out nil 
start end))
            ((string-match (regexp-quote rcd-check-out) line)
             (replace-regexp (regexp-quote rcd-check-out) rcd-check-in nil 
start end))))))

(defvar rcd-check-in "❰    ❱")
(defvar rcd-check-out "❰DONE❱")

(defun rcd-check-start ()
  "Insert variable `rcd-check-in' at the beginning of line."
  (interactive)
  (let* ((start (line-beginning-position))
         (end (line-end-position))
         (line (buffer-substring start end)))
    (when (and (not (string-match rcd-check-in line))
               (not (string-match rcd-check-out line)))
      (save-excursion
        (goto-char start)
        (insert rcd-check-in " "))
      (when (= start end)
        (goto-char (line-end-position))))))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]