all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch: Convenience function for changing font family
@ 2021-08-06  9:03 Anand Tamariya
  2021-08-06  9:36 ` Andreas Schwab
  2021-08-08  6:32 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Anand Tamariya @ 2021-08-06  9:03 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

Here's a patch for changing the font family on the fly. It's similar to
changing font weight using the keyboard.


diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index b10d874b21..3342b1d4a1 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -103,7 +103,8 @@ facemenu-keybindings
   '((default     . "d")
     (bold        . "b")
     (italic      . "i")
-    (bold-italic . "l") ; {bold} intersect {italic} = {l}
+    (bold-italic . "l") ; {bold} intersect {italic} = {l}/
+    (family      . "f")
     (underline   . "u")))
   "Alist of interesting faces and keybindings.
 Each element is itself a list: the car is the name of the face,
@@ -339,6 +340,16 @@ facemenu-set-face
   (facemenu-add-new-face face)
   (facemenu-add-face face start end))

+(defun facemenu-set-family (family &optional start end)
+  (interactive (list (progn
+                      (barf-if-buffer-read-only)
+                      (completing-read "Font family: " (font-family-list)))
+                    (if (and mark-active (not current-prefix-arg))
+                        (region-beginning))
+                    (if (and mark-active (not current-prefix-arg))
+                        (region-end))))
+  (add-text-properties start end `(face (:family ,family))))
+
 (defun facemenu-set-foreground (color &optional start end)
   "Set the foreground COLOR of the region or next character typed.
 This command reads the color in the minibuffer.

[-- Attachment #2: Type: text/html, Size: 1834 bytes --]

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

end of thread, other threads:[~2021-08-09  6:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-06  9:03 Patch: Convenience function for changing font family Anand Tamariya
2021-08-06  9:36 ` Andreas Schwab
2021-08-08  6:32 ` Eli Zaretskii
2021-08-09  6:51   ` Anand Tamariya

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.