From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Changing font Date: Fri, 18 May 2007 21:21:35 +0200 Message-ID: <87wsz6x7i8.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hp81G-0008WA-OE for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:21:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hp81E-0008Vy-BQ for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:21:41 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hp81E-0008Vv-5K for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:21:40 -0400 Received: from ug-out-1314.google.com ([66.249.92.170]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hp81D-0007qO-RM for emacs-orgmode@gnu.org; Fri, 18 May 2007 15:21:40 -0400 Received: by ug-out-1314.google.com with SMTP id j3so536113ugf for ; Fri, 18 May 2007 12:21:39 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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