* Changing font
@ 2007-05-18 19:21 Bastien
0 siblings, 0 replies; only message in thread
From: Bastien @ 2007-05-18 19:21 UTC (permalink / raw)
To: emacs-orgmode
Hi,
i'm using this bunch of defuns for a long time now and i think it might
comes in handy for others. It allows you to quickly change the font
markers around the selected text.
I'm using "C-c f [key]" rather than the more expected "C-c C-f [key]"
(see latex-mode) because "C-c C-f" is already taken by outline-mode.
========================================================================
(org-defkey org-mode-map "\C-cfb" 'my-org-change-font-bold)
(org-defkey org-mode-map "\C-cfe" 'my-org-change-font-emphasis)
(org-defkey org-mode-map "\C-cfu" 'my-org-change-font-underline)
(org-defkey org-mode-map "\C-cft" 'my-org-change-font-truetype)
(org-defkey org-mode-map "\C-cfn" 'my-org-change-font-normal)
(defun my-org-change-font (tagbeg tagend)
"Insert TAGBEG and TAGEND at the beginning/end of a region."
(let* ((beg (if (org-region-active-p) (mark) (point)))
(end (point)) (temp beg) (spcs '(?* ?= ?_ ?/)))
(when (< end beg) (setq beg end end temp))
(goto-char beg)
(while (memq (char-before (point)) spcs)
(delete-char -1)
(setq end (1- end)))
(insert tagbeg)
(goto-char (+ (length tagbeg) end))
(while (memq (char-after (point)) spcs)
(delete-char 1))
(save-excursion (insert tagend))))
(defun my-org-change-font-bold ()
"Change font to bold."
(interactive)
(my-org-change-font "*" "*"))
(defun my-org-change-font-emphasis ()
"Change font to emphasis."
(interactive)
(my-org-change-font "/" "/"))
(defun my-org-change-font-truetype ()
"Change font to truetype."
(interactive)
(my-org-change-font "=" "="))
(defun my-org-change-font-underline ()
"Change font to underline."
(interactive)
(my-org-change-font "_" "_"))
(defun my-org-change-font-normal ()
"Strip any font beautifier."
(interactive)
(my-org-change-font "" ""))
========================================================================
--
Bastien
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-05-18 19:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-18 19:21 Changing font Bastien
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).