From: Ypo <ypuntot@gmail.com>
To: Ruijie Yu <ruijie@netyu.xyz>
Cc: emacs-orgmode@gnu.org
Subject: Re: Help using org-entities or arternatives.
Date: Sat, 13 May 2023 18:43:43 +0200 [thread overview]
Message-ID: <711f83e9-a490-6a4c-f044-de0d67e648e8@gmail.com> (raw)
In-Reply-To: <sdvlehxbtdi.fsf@netyu.xyz>
[-- 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 --]
prev parent reply other threads:[~2023-05-13 16:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=711f83e9-a490-6a4c-f044-de0d67e648e8@gmail.com \
--to=ypuntot@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=ruijie@netyu.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).