From: Bruno Barbier <brubar.cs@gmail.com>
To: pareto optimal <pareto.optimal@mailfence.com>,
Emacs Orgmode <emacs-orgmode@gnu.org>
Subject: Re: RFC on implementation adding buttons beside headings
Date: Mon, 20 Feb 2023 20:17:20 +0100 [thread overview]
Message-ID: <63f3c742.df0a0220.58f3d.75fe@mx.google.com> (raw)
In-Reply-To: <418353827.205931.1676736087884@fidget.co-bxl>
pareto optimal <pareto.optimal@mailfence.com> writes:
> I found the only way to place the button where I wanted was to insert
> some blank space after the heading. Is that expected and best practice
> or is there some other way to do it?
FWIW, instead of inserting some blank spaces, you could overlay existing
characters, you'll just need to re-inject them at display time so that
the display doesn't change. That way, you don't modified the text.
Here is a way to add a button, in place, without modifying the
buffer. The trick is to overlay the EOL and to re-inject an EOL
using the "after-string" property.
(with-current-buffer (generate-new-buffer "=test")
(cl-flet ((run (f) (lambda (&rest args) (interactive) (funcall f))))
(let (pos)
(insert "* My title\n")
(setq pos (1- (point)))
(insert "An amazing note.\n\n")
(insert "** My 2 title\n")
(insert "An even more amazing note.\n")
(org-mode)
(make-button pos (1+ pos)
'before-string "\n\n "
'display '((height 2) "Click me!")
'after-string "\n\n"
'face 'custom-button
'action (run (lambda () (message "Thanks!")))
)))
(pop-to-buffer (current-buffer))
)
Note that the above expression requires lexical-binding.
Bruno
next prev parent reply other threads:[~2023-02-20 19:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 16:00 RFC on implementation adding buttons beside headings pareto optimal
2023-02-18 16:01 ` pareto optimal
2023-02-20 19:17 ` Bruno Barbier [this message]
2023-02-19 11:04 ` Ihor Radchenko
2023-02-19 22:57 ` Samuel Wales
[not found] ` <292424133.47705.1676856972523@fidget.co-bxl>
2023-02-20 13:23 ` Ihor Radchenko
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=63f3c742.df0a0220.58f3d.75fe@mx.google.com \
--to=brubar.cs@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=pareto.optimal@mailfence.com \
/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).