Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'd like to programmatically save (and then temporarily change and restore) specific printing options. I get as far as

Options[Notebook, PrintingOptions]

but don't know what to do next to extract specific options, for example PrintingMargins, from the (long) resulting list.

share|improve this question
    
Doesn't "PrintingMargins" /. (PrintingOptions /. Options[Notebook, PrintingOptions]) work for you? –  J. M. Nov 15 '12 at 23:20
    
@J.M.: That works. There's no API for extracting nested options? –  raxacoricofallapatorius Nov 15 '12 at 23:21
    
API, nothing. What would be the trouble with using ReplaceAll anyway? –  J. M. Nov 15 '12 at 23:44
    
@J.M.: No problem, I just expected something more compact and targeted to options. –  raxacoricofallapatorius Nov 15 '12 at 23:54
4  
You kids today don't know how good you've got it! When I were a lad, ReplaceAll was all we had for option handling! We'd make six nested replacements to process our options, with Hold and Release for evaluation control, and Block our only scoping construct. And we were thankful! –  Oleksandr R. Nov 16 '12 at 0:15
show 1 more comment

1 Answer

up vote 3 down vote accepted
 CurrentValue[Notebook, {PrintingOptions, "PrintingMargins"}]
 (* {{54, 54}, {72, 72}} *) 

You can also use $FrontEnd , EvaluationNotebook[] ... as the first argument.

Other examples:

 CurrentValue[$FrontEnd, EvaluatorNames]
     (* {"Local" -> {"AutoStartOnLaunch" -> True}} *)
     CurrentValue[$FrontEnd, {EvaluatorNames, "Local"}]
 (* {"AutoStartOnLaunch" -> True} *)
 CurrentValue[$FrontEnd, {EvaluatorNames, "Local", "AutoStartOnLaunch"}]
 (* True *)

Update: See also this Q/A: Items known by CurrentValue.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.