* Help using org-entities or arternatives.
@ 2023-05-09 11:32 Ypo
2023-05-09 11:48 ` Ruijie Yu via General discussions about Org-mode.
0 siblings, 1 reply; 3+ messages in thread
From: Ypo @ 2023-05-09 11:32 UTC (permalink / raw)
To: Org-mode
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 1451 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help using org-entities or arternatives.
2023-05-09 11:32 Help using org-entities or arternatives Ypo
@ 2023-05-09 11:48 ` Ruijie Yu via General discussions about Org-mode.
2023-05-13 16:43 ` Ypo
0 siblings, 1 reply; 3+ messages in thread
From: Ruijie Yu via General discussions about Org-mode. @ 2023-05-09 11:48 UTC (permalink / raw)
To: Ypo; +Cc: emacs-orgmode
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))))
```
--
Best,
RY
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help using org-entities or arternatives.
2023-05-09 11:48 ` Ruijie Yu via General discussions about Org-mode.
@ 2023-05-13 16:43 ` Ypo
0 siblings, 0 replies; 3+ messages in thread
From: Ypo @ 2023-05-13 16:43 UTC (permalink / raw)
To: Ruijie Yu; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]
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))))
> ```
>
[-- Attachment #2: Type: text/html, Size: 2334 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-13 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-09 11:32 Help using org-entities or arternatives Ypo
2023-05-09 11:48 ` Ruijie Yu via General discussions about Org-mode.
2023-05-13 16:43 ` Ypo
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.