all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Inserting heading level and titile from first non-blank line
@ 2024-03-29  9:34 Heime
  2024-03-29  9:43 ` Emanuel Berg
  2024-03-29 12:59 ` Heime
  0 siblings, 2 replies; 3+ messages in thread
From: Heime @ 2024-03-29  9:34 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I am adding a heading with the following function using (outline-insert-heading).
And want ta adapt it for a user to select the heading level. As the title, of the heading I want to use the first non-blank line that follows the position of the  heading.

(defun kinus ()
  (interactive)
  (outline-insert-heading))



Sent with Proton Mail secure email.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Inserting heading level and titile from first non-blank line
  2024-03-29  9:34 Inserting heading level and titile from first non-blank line Heime
@ 2024-03-29  9:43 ` Emanuel Berg
  2024-03-29 12:59 ` Heime
  1 sibling, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2024-03-29  9:43 UTC (permalink / raw)
  To: help-gnu-emacs

Heime wrote:

> And want ta adapt it for a user to select the heading level.
> As the title, of the heading I want to use the first
> non-blank line that follows the position of the heading.
>
> (defun kinus ()
>   (interactive)
>   (outline-insert-heading))

You must add additional Elisp to achieve that.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Inserting heading level and titile from first non-blank line
  2024-03-29  9:34 Inserting heading level and titile from first non-blank line Heime
  2024-03-29  9:43 ` Emanuel Berg
@ 2024-03-29 12:59 ` Heime
  1 sibling, 0 replies; 3+ messages in thread
From: Heime @ 2024-03-29 12:59 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Friday, March 29th, 2024 at 9:34 PM, Heime <heimeborgia@protonmail.com> wrote:

> I am adding a heading with the following function using (outline-insert-heading).
> And want ta adapt it for a user to select the heading level. As the title, of the heading I want to use the first non-blank line that follows the position of the heading.
> 
> (defun kinus ()
> (interactive)
> (outline-insert-heading))

Have added save-excursion, but the insertion still happens at the
end of the line match, rather than at point.

(defun kinus ()
  (interactive)
  (save-excursion
    (forward-line)
    (while (looking-at "^[[:space:]]*$") (forward-line))
    (insert (buffer-substring
      (line-beginning-position) (line-end-position))) ))




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-29 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29  9:34 Inserting heading level and titile from first non-blank line Heime
2024-03-29  9:43 ` Emanuel Berg
2024-03-29 12:59 ` Heime

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.