emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: Convenience function for changing font family


From: Anand Tamariya
Subject: Patch: Convenience function for changing font family
Date: Fri, 6 Aug 2021 14:33:48 +0530

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]