From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Commands to insert a heading and a new page
Date: Thu, 28 Mar 2024 04:12:02 +0100 [thread overview]
Message-ID: <87plvfxd6l.fsf@dataswamp.org> (raw)
In-Reply-To: 87le63fg07.fsf@gmail.com
tpeplt wrote:
> A simple function to insert a form-feed character:
>
> (defun new-page ()
> "Insert a page separator into the current buffer."
> (interactive)
> (newline)
> (insert ?\f) ;Form feed is \f or Ctrl-l or ASCII 012
> (newline))
It is not used so often, why and when do you use it?
> ‘insert’ accepts either characters or strings, so it could
> be used to define a command that inserts whatever text you
> want in a heading.
>
> (newline)
> (insert "Header line 1\n")
> (insert "Line 2\n")
> (insert (format "Parameter is %s.\n" parm))
Here is a bunch of Elisp that maybe amuses you:
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/string.el
(defun sign (label &optional no-insert)
(interactive "sLabel: \nP")
(let*((vertical "|")
(horizontal ?-)
(corner "+")
(mid (format "%s %s %s" vertical label vertical))
(len (length mid))
(top (format "%s%s%s" corner (make-string (- len 2) horizontal) corner))
(sgn (format "%s\n%s\n%s\n" top mid top)) )
(if no-insert
sgn
(insert sgn) )))
;; +---------------------+
;; | This is not a bluff |
;; +---------------------+
(defun hline (&optional char)
(interactive "P")
(let ((len (- (window-width) (or (current-column) 0) 1))
(c (or (and (listp char) (car char))
(and (numberp char) char)
?-) ))
(insert (make-string len c)) ))
(defalias 'hl #'hline)
(when nil
(hline)----------------------------------------------------------------------
(hline 42)*******************************************************************
(hline ?+)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M-x hline RET----------------------------------------------------------------
C-u C-u C-u M-x hline RET@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
C-u 59 M-x hline RET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
)
(defun string-data-p (str)
(and (stringp str)
(not (string= str ""))
str) )
(defun region-to-string ()
(when (use-region-p)
(let ((beg (region-beginning))
(end (region-end) ))
(let ((str (buffer-substring-no-properties beg end)))
(replace-regexp-in-string "\n" " " str) ))))
(provide 'string)
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2024-03-28 3:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-26 9:16 Commands to insert a heading and a new page Heime
2024-03-27 22:48 ` tpeplt
2024-03-28 3:12 ` Emanuel Berg [this message]
2024-03-31 15:49 ` [External] : " Drew Adams
2024-03-31 18:40 ` tpeplt
2024-03-31 20:32 ` Drew Adams
2024-04-01 2:07 ` Emanuel Berg
2024-04-01 16:53 ` Drew Adams
2024-04-01 1:20 ` Emanuel Berg
2024-03-28 9:42 ` Heime
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.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87plvfxd6l.fsf@dataswamp.org \
--to=incal@dataswamp.org \
--cc=help-gnu-emacs@gnu.org \
/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.
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).