all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* insert-string-centered / column before $ appears?
@ 2020-03-03 23:21 Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; only message in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-03-03 23:21 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: emacs-devel

(defun insert-string-centered (string &optional far-right)
  (interactive
   `(,(read-from-minibuffer "string: ")
     ,(string-to-number
       (read-from-minibuffer "far-right column [default 69]: ") )))
  (let*((max         (if (< 0 far-right) far-right 69))
        (str-len     (length string))
        (padding     (+ (/ (- max str-len) 2)
                        (if (= 0 (mod str-len 2)) 1 0)))
        (padding-str (make-string padding ?\ )))
    (insert padding-str string) ))

One (?) issue: 69 which is hardcoded above is the column that
appears right before the $ char appears in Emacs.

I take it this is stored somewhere?

Tested on this file: https://dataswamp.org/~incal/FILM

Source: https://dataswamp.org/~incal/emacs-init/edit.el

--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-03 23:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-03 23:21 insert-string-centered / column before $ appears? Emanuel Berg via Users list for the GNU Emacs text editor

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.