From mboxrd@z Thu Jan 1 00:00:00 1970 From: 42 147 Subject: Re: hiding footnotes Date: Thu, 29 Nov 2012 02:40:06 -0500 Message-ID: References: <87sj7t4p0l.fsf@gmail.com> <3483.1354165215@alphaville> <87zk217ww5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8f3b9f7d499c9e04cf9d6423 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:37307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdyjF-0000EK-RV for emacs-orgmode@gnu.org; Thu, 29 Nov 2012 02:40:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tdyj9-0003Dd-7J for emacs-orgmode@gnu.org; Thu, 29 Nov 2012 02:40:13 -0500 Received: from mail-ia0-f169.google.com ([209.85.210.169]:56441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tdyj9-0003CZ-0i for emacs-orgmode@gnu.org; Thu, 29 Nov 2012 02:40:07 -0500 Received: by mail-ia0-f169.google.com with SMTP id r4so12853900iaj.0 for ; Wed, 28 Nov 2012 23:40:06 -0800 (PST) In-Reply-To: <87zk217ww5.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jambunathan K Cc: Nick Dokos , emacs-orgmode@gnu.org --e89a8f3b9f7d499c9e04cf9d6423 Content-Type: text/plain; charset=ISO-8859-1 I added this to my .emacs: (defun t-face () "to pass org-footnote automatically to toggle-face" (interactive) (toggle-face 'org-footnote)) (defun toggle-face (&optional face-from) (interactive (list (read-face-name "Face" (face-at-point)))) (let ((f (assq face-from face-remapping-alist)) (face-to 'default)) (if f (setq face-remapping-alist (delq f face-remapping-alist)) (push (cons face-from face-to) face-remapping-alist)))) On Thu, Nov 29, 2012 at 1:20 AM, Jambunathan K wrote: > Nick Dokos writes: > > > 42 147 wrote: > > > >> Very nice. > >> > >> However, I'd like to write a function that toggles the color value > (without > >> recourse to the customize menu), since it would be useful to highlight > the > >> footnotes from time to time. > >> > > > > Anything that can be done interactively can also be done > > programatically. You know what face you are dealing with, you can get > > its foreground color with face-foreground, and you can set it with > > set-face-attribute. A crude implementation to show the basic outline: > > > > > > (setq org-footnote-fg-color (face-foreground 'org-footnote)) > > > > (setq org-text-fg-color (face-foreground 'default)) > > > > (defun my-toggle-footnote-fg-color () > > "Toggle the org-footnote face foreground color." > > (interactive) > > (let ((fg (face-foreground 'org-footnote))) > > (if (string-equal fg org-footnote-fg-color) > > (set-face-attribute 'org-footnote nil :foreground > org-text-fg-color) > > (set-face-attribute 'org-footnote nil :foreground > org-footnote-fg-color)))) > > > > > > The difficulties start (but do not end) with footnotes in all sorts of > > weird places (e.g. headlines) with all sorts of different > > fontifications. You'd want to blend the footnote with its immediate > > surroundings. > > > > Taking care of such situations (and various others that the above code > > mishandles) is left as an exercise... > > Install the following defun, put the cursor on fontified text and do M-x > toggle-face. > > (defun toggle-face (&optional face-from) > (interactive (list (read-face-name "Face" (face-at-point)))) > (let ((f (assq face-from face-remapping-alist)) > (face-to 'default)) > (if f (setq face-remapping-alist (delq f face-remapping-alist)) > (push (cons face-from face-to) face-remapping-alist)))) > > See also (info "(elisp) Face Remapping") > > > > > Nick > > > > > > -- > --e89a8f3b9f7d499c9e04cf9d6423 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I added this to my .emacs:

(defun t-face ()
"to pass org-foo= tnote automatically to toggle-face"
=A0 (interactive)
(toggle-fa= ce 'org-footnote))

(defun toggle-face (&optional face-from)<= br> =A0 (interactive (list (read-face-name "Face" (face-at-point))))<= br>=A0 (let ((f (assq face-from face-remapping-alist))
=A0=A0=A0 (face-t= o 'default))
=A0=A0=A0 (if f (setq face-remapping-alist (delq f face= -remapping-alist))
=A0=A0=A0=A0=A0 (push (cons face-from face-to) face-remapping-alist))))
=

On Thu, Nov 29, 2012 at 1:20 AM, Jambuna= than K <kjambunathan@gmail.com> wrote:
Nick Dokos <nicholas.dokos@hp.com> writes:

> 42 147 <aeuster@gmail.com&= gt; wrote:
>
>> Very nice.
>>
>> However, I'd like to write a function that toggles the color v= alue (without
>> recourse to the customize menu), since it would be useful to highl= ight the
>> footnotes from time to time.
>>
>
> Anything that can be done interactively can also be done
> programatically. You know what face you are dealing with, you can get<= br> > its foreground color with face-foreground, and you can set it with
> set-face-attribute. A crude implementation to show the basic outline:<= br> >
>
> (setq org-footnote-fg-color (face-foreground &= #39;org-footnote))
>
> (setq org-text-fg-color (face-foreground 'default))
>
> (defun my-toggle-footnote-fg-color ()
> =A0 "Toggle the org-footnote face foreground color."
> =A0 (interactive)
> =A0 (let ((fg (face-foreground 'org-footnote)))
> =A0 =A0 (if (string-equal fg org-footnote-fg-color)
> =A0 =A0 =A0 (set-face-attribute 'org-footnote nil :foreground org-= text-fg-color)
> =A0 =A0 =A0 (set-face-attribute 'org-footnote nil :foreground org-= footnote-fg-color))))
>
>
> The difficulties start (but do not end) with f= ootnotes in all sorts of
> weird places (e.g. headlines) with all sorts of different
> fontifications. You'd want to blend the footnote with its immediat= e
> surroundings.
>
> Taking care of such situations (and various others that the above code=
> mishandles) is left as an exercise...

Install the following defun, put the cursor on fontified text and do = M-x
toggle-face.

=A0 =A0 (defun toggle-face (&optional face-from)
=A0 =A0 =A0 (interactive (list (read-face-name "Face" (face-at-po= int))))
=A0 =A0 =A0 (let ((f (assq face-from face-remapping-alist))
=A0 =A0 =A0 =A0 =A0 =A0 (face-to 'default))
=A0 =A0 =A0 =A0 (if f (setq face-remapping-alist (delq f face-remapping-ali= st))
=A0 =A0 =A0 =A0 =A0 (push (cons face-from face-to) face-remapping-alist))))=

See also (info "(elisp) Face Remapping")



> Nick
>
>

--

--e89a8f3b9f7d499c9e04cf9d6423--