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

* Re: Patch: Convenience function for changing font family
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2021-08-06  9:36 UTC (permalink / raw)
  To: Anand Tamariya; +Cc: emacs-devel

On Aug 06 2021, Anand Tamariya wrote:

> 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}/

Spurious change.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



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

* Re: Patch: Convenience function for changing font family
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2021-08-08  6:32 UTC (permalink / raw)
  To: Anand Tamariya; +Cc: emacs-devel

> From: Anand Tamariya <atamariya@gmail.com>
> 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.

Thanks, but how is this supposed to work?  After applying the patch
and loading facemenu, "M-x facemenu-set-family RET" does nothing, not
even prompts for the font family; and clicking

 Edit->Text Properties->Face->family

from the menu bar just shows "menu-bar edit Text Properties fc f" in
the echo area.

I think one problem is that the facemenu machinery, as you use it,
expects "family" to be a face, and there's no such face.

Did you test this with Emacs 28 from the master branch?  Or what am I
missing?

P.S. Please also provide a doc string for the new function(s), and add
a :version tag to any defcustom you add or change.



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

* Re: Patch: Convenience function for changing font family
  2021-08-08  6:32 ` Eli Zaretskii
@ 2021-08-09  6:51   ` Anand Tamariya
  0 siblings, 0 replies; 4+ messages in thread
From: Anand Tamariya @ 2021-08-09  6:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

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

On Sun, Aug 8, 2021 at 12:02 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Anand Tamariya <atamariya@gmail.com>
> > 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.
>
> Thanks, but how is this supposed to work?  After applying the patch
> and loading facemenu, "M-x facemenu-set-family RET" does nothing, not
> even prompts for the font family; and clicking
>
>  Edit->Text Properties->Face->family
>
> from the menu bar just shows "menu-bar edit Text Properties fc f" in
> the echo area.
>
> I think one problem is that the facemenu machinery, as you use it,
> expects "family" to be a face, and there's no such face.
>
> Did you test this with Emacs 28 from the master branch?  Or what am I
> missing?
>
> P.S. Please also provide a doc string for the new function(s), and add
> a :version tag to any defcustom you add or change.
>
You are right. I don't understand the face menu system well. It worked for
me because I was evaluating the changes in a running instance. Once I start
a new instance, I can't seem to get it working without re-evaluating
'facemenu-keybindings' followed by (facemenu-update). Also, it's only
supposed to work on a selection of text, i.e. you select some text and then
change the font family for the selection.

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

^ permalink raw reply	[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.