emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Help using org-entities or arternatives.


From: Ypo
Subject: Re: Help using org-entities or arternatives.
Date: Sat, 13 May 2023 18:43:43 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Thanks, Ruijie. I think it is not what I was asking for, but it's nice to read your code.

Best regards.

El 09/05/2023 a las 13:48, Ruijie Yu escribió:
Ypo <ypuntot@gmail.com> writes:

Hi

Is it possible to, each time I write "...." to be subsituted by "[...]" ?

I can't do it using abbrev, and I don't know how to do it using org-entities.

I use it to yank quotes, for example, I write:

 "Like other editors, Emacs has commands to search for occurrences of a string. ....There are also commands that do the same thing, but
 search for patterns instead of fixed strings."

And I would like to get, automatically:

 "Like other editors, Emacs has commands to search for occurrences of a string. [...] There are also commands that do the same thing, but
 search for patterns instead of fixed strings."

Best regards
Not necessarily Org-specific, but here's my idea, untested:

```emacs-lisp
(defun my/yank-subst-ellipses ()
  (interactive)
  (let* ((start (point-marker))
         (_ (insert (current-kill 0)))
         (end (point-marker)))
    (save-match-data
      ;; Play around with this regexp
      (while (re-search-forward (rx "...") end t)
        ;; And this replacement text
        (replace-match "[...]")))))
```

Then, since Org sets C-y as `org-yank', make an advice with it.  I am
not confident in this portion at all, but here goes nothing ;)

```emacs-lisp
(require 'cl-lib)
(advice-add
 #'org-yank :around
 (lambda (org-yank &optional arg)
   (cl-letf (((symbol-function 'yank)
              (symbol-function 'my/yank-subst/ellipses)))
     (funcall org-yank arg))))
```


reply via email to

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