unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* When/where does setq work?
@ 2014-04-02  7:00 Rusi
  2014-04-02 12:57 ` lee
  0 siblings, 1 reply; 7+ messages in thread
From: Rusi @ 2014-04-02  7:00 UTC (permalink / raw)
  To: help-gnu-emacs

I have the following function.
It sets the org-export-html-style variable to inline CSS.


----------------------------
(defun load-my-css()
  "Returns string from css file (hardwired) suitable for inline css"
  (interactive)
  (setq org-export-html-style
	(with-temp-buffer
	  (insert "\n<style type=\"text/css\">\n")
	  (insert-file-contents (expand-file-name "my-org.css" "~/orghacks"))
	  (goto-char (point-max))
	  (insert "\n</style>\n")
	  (buffer-string))))


(load-my-css)
------------------------------


The intent is that for various reasons I want inline CSS not a linked style sheet.
Towards that it reads the my-org.css file into a temp-buffer and stores that 
into a suitable style variable.

Now it works... kinda but not properly.
That is it works once from my init.
However 
1. edit my-org.css
2. save
3. M-x load-my-css
has no effect

Restart emacs and it takes effect

Any clues??


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

* Re: When/where does setq work?
  2014-04-02  7:00 When/where does setq work? Rusi
@ 2014-04-02 12:57 ` lee
  2014-04-02 18:06   ` Florian v. Savigny
       [not found]   ` <mailman.18759.1396461983.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: lee @ 2014-04-02 12:57 UTC (permalink / raw)
  To: help-gnu-emacs

Rusi <rustompmody@gmail.com> writes:

> I have the following function.
> It sets the org-export-html-style variable to inline CSS.
>
>
> ----------------------------
> (defun load-my-css()
>   "Returns string from css file (hardwired) suitable for inline css"
>   (interactive)
>   (setq org-export-html-style
> 	(with-temp-buffer
> 	  (insert "\n<style type=\"text/css\">\n")
> 	  (insert-file-contents (expand-file-name "my-org.css" "~/orghacks"))
> 	  (goto-char (point-max))
> 	  (insert "\n</style>\n")
> 	  (buffer-string))))
>
>
> (load-my-css)
> ------------------------------
>
>
> The intent is that for various reasons I want inline CSS not a linked style sheet.
> Towards that it reads the my-org.css file into a temp-buffer and stores that 
> into a suitable style variable.
>
> Now it works... kinda but not properly.
> That is it works once from my init.
> However 
> 1. edit my-org.css
> 2. save
> 3. M-x load-my-css
> has no effect
>
> Restart emacs and it takes effect

Where and how is `org-export-html-style' declared and used?  Are you
sure its value does not change when the function is called and that the
function returns what you are expecting?


-- 
Knowledge is volatile and fluid.  Software is power.



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

* Re: When/where does setq work?
  2014-04-02 12:57 ` lee
@ 2014-04-02 18:06   ` Florian v. Savigny
       [not found]   ` <mailman.18759.1396461983.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Florian v. Savigny @ 2014-04-02 18:06 UTC (permalink / raw)
  To: lee; +Cc: help-gnu-emacs



  > > 1. edit my-org.css
  > > 2. save
  > > 3. M-x load-my-css
  > > has no effect

One might add to Eli's questions (even if that is simply what he
means, only in more words): What exactly do you mean by "no effect"?
One would assume that you mean that C-h v org-export-html-style tells
you that the variable still has the old value. But one should never
assume; maybe you do something more high-level and that is how you
notice that the old value is still used.

Assuming ;-) that you ARE sure that the value of the variable does not
change: Have you tried M-x edebug-defun inside the definition of
load-my-css, and then calling it? It might go some of the way towards
anwering Eli's second question.

Best regards,

Florian

-- 

Florian von Savigny
Melanchthonstr. 41
33615 Bielefeld




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

* Re: When/where does setq work?
       [not found]   ` <mailman.18759.1396461983.10748.help-gnu-emacs@gnu.org>
@ 2014-04-02 22:04     ` Rusi
  2014-04-02 23:02       ` Florian v. Savigny
       [not found]       ` <mailman.18784.1396479749.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Rusi @ 2014-04-02 22:04 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday, April 2, 2014 11:36:14 PM UTC+5:30, Florian v. Savigny wrote:
> > > 1. edit my-org.css
>   > > 2. save
>   > > 3. M-x load-my-css
>   > > has no effect

> One might add to Eli's questions (even if that is simply what he
> means, only in more words): What exactly do you mean by "no effect"?
> One would assume that you mean that C-h v org-export-html-style tells
> you that the variable still has the old value. But one should never
> assume; maybe you do something more high-level and that is how you
> notice that the old value is still used.

> Assuming ;-) that you ARE sure that the value of the variable does not
> change: Have you tried M-x edebug-defun inside the definition of
> load-my-css, and then calling it? It might go some of the way towards
> anwering Eli's second question.

org-export-html-style is an org-mode variable defined in org-html.el.

Its 'effect' is the css styles that are used by org's html export

eg
code {
    color: #00f;
}

makes the color of code in <code> </code> blocks blue

Now I edit my-org.css

code {
    color: #7f7f7f
}

(ie the new color is now grey)
And I export the (some) org file I am working on.
It still shows as blue.
This is what I mean by "no effect"

I exit and restart emacs

Open my org file again

Export to html
Now its grey


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

* Re: When/where does setq work?
  2014-04-02 22:04     ` Rusi
@ 2014-04-02 23:02       ` Florian v. Savigny
       [not found]       ` <mailman.18784.1396479749.10748.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Florian v. Savigny @ 2014-04-02 23:02 UTC (permalink / raw)
  To: Rusi; +Cc: help-gnu-emacs


Hi Rusi,

  > org-export-html-style is an org-mode variable defined in org-html.el.
  > 
  > Its 'effect' is the css styles that are used by org's html export
  > 
  > eg
  > code {
  >     color: #00f;
  > }
  > 
  > makes the color of code in <code> </code> blocks blue
  > 
  > Now I edit my-org.css
  > 
  > code {
  >     color: #7f7f7f
  > }
  > 
  > (ie the new color is now grey)

But at this point you run your load-my-css, don't you?

  > And I export the (some) org file I am working on.
  > It still shows as blue.
  > This is what I mean by "no effect"
  
This is the kind of scenario that we were hinting at: Chances are that
there are simply some added layers of complexity between the variable
and its effect (for whatever technological reason - as humans, we find
this counterintuitive). Example: When loaded, org-html.el sets a
variable to the value of org-export-html-style. (In that case,
reloading org-html.el after running load-my-css should have the same
effect as restarting emacs.)  But this is just an example for
illustration. It is better to simply try:

C-h v org-export-html-style

after running load-my-css as I have indicated above. My guess is it's
perfectly set to the new value then. If not, try the edebug-defun
method and report, please.

Regards,

Florian

-- 

Florian von Savigny
Melanchthonstr. 41
33615 Bielefeld




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

* Re: When/where does setq work?
       [not found]       ` <mailman.18784.1396479749.10748.help-gnu-emacs@gnu.org>
@ 2014-04-03  4:04         ` Rusi
  2014-04-03 14:49           ` Florian v. Savigny
  0 siblings, 1 reply; 7+ messages in thread
From: Rusi @ 2014-04-03  4:04 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday, April 3, 2014 4:32:19 AM UTC+5:30, Florian v. Savigny wrote:
> Hi Rusi,

>   > org-export-html-style is an org-mode variable defined in org-html.el.
>   > Its 'effect' is the css styles that are used by org's html export
>   > eg
>   > code {
>   >     color: #00f;
>   > }
>   > makes the color of code in <code> </code> blocks blue
>   > Now I edit my-org.css
>   > code {
>   >     color: #7f7f7f
>   > }
>   > (ie the new color is now grey)

> But at this point you run your load-my-css, don't you?

>   > And I export the (some) org file I am working on.
>   > It still shows as blue.
>   > This is what I mean by "no effect"

> This is the kind of scenario that we were hinting at: Chances are that
> there are simply some added layers of complexity between the variable
> and its effect (for whatever technological reason - as humans, we find
> this counterintuitive). Example: When loaded, org-html.el sets a
> variable to the value of org-export-html-style. (In that case,
> reloading org-html.el after running load-my-css should have the same
> effect as restarting emacs.)  But this is just an example for
> illustration. It is better to simply try:

> C-h v org-export-html-style

> after running load-my-css as I have indicated above. My guess is it's
> perfectly set to the new value then. If not, try the edebug-defun
> method and report, please.

Yes its getting set.

So now it looks that org mode is 'early-binding' that variable:
ie its using the initial value of that variable and not using the
new value when/if its changed.

However thats strange since, even after org-reload it keeps its old value...

Guess I'll ask on the org list.


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

* Re: When/where does setq work?
  2014-04-03  4:04         ` Rusi
@ 2014-04-03 14:49           ` Florian v. Savigny
  0 siblings, 0 replies; 7+ messages in thread
From: Florian v. Savigny @ 2014-04-03 14:49 UTC (permalink / raw)
  To: Rusi; +Cc: help-gnu-emacs



  > Yes its getting set.
  > 
  > So now it looks that org mode is 'early-binding' that variable:
  > ie its using the initial value of that variable and not using the
  > new value when/if its changed.
  > 
  > However thats strange since, even after org-reload it keeps its
  > old value...

So this style information is kept and used across a complete reload?
Maybe a variable is set using defvar? (That only sets variables whose
value is void.) In any case, it's apparently still less simplistic
than I imagined.

  > Guess I'll ask on the org list.

Probably yes. I have had a quick peek into the org-mode source files,
but even where the variable is used was not exactly obvious to the
naked eye. - In any case, it looks like the variable is not meant, or
at least not designed, for on-the-fly customization, but maybe there
is another way. (Before you start hacking the whole thing.)

By the way: I referred to the other poster as "Eli" (believing it was
Eli Zaretski who wrote the other posts). It was really somebody
apparently called Lee - my eyes had confused two header lines. My
apologies to both!

Regards,

Florian

-- 

Florian von Savigny
Melanchthonstr. 41
33615 Bielefeld




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

end of thread, other threads:[~2014-04-03 14:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02  7:00 When/where does setq work? Rusi
2014-04-02 12:57 ` lee
2014-04-02 18:06   ` Florian v. Savigny
     [not found]   ` <mailman.18759.1396461983.10748.help-gnu-emacs@gnu.org>
2014-04-02 22:04     ` Rusi
2014-04-02 23:02       ` Florian v. Savigny
     [not found]       ` <mailman.18784.1396479749.10748.help-gnu-emacs@gnu.org>
2014-04-03  4:04         ` Rusi
2014-04-03 14:49           ` Florian v. Savigny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).