13
$\begingroup$

If I go to the menu bar and press File I get a list of recently opened files.This would be useful except they are edited and mostly replaced by dots thus making choosing difficult. See the screen shot below. Is it possible to get the non abbreviated list from within mathematica and then open one of the notebooks?

I started looking at Preferences and found the "Recently opened files history length" but could not find more. I could not find this as a previous question but may not have searched exhaustively.

Thanks

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ This doesn't happen on OSX so it's probably how Windows handles wide entries in drop down menus. $\endgroup$ – N.J.Evans Jul 9 '15 at 13:38
  • $\begingroup$ @N.J.Evans Yes I am using windows. Can we find a workaround? $\endgroup$ – Hugh Jul 9 '15 at 15:32
5
$\begingroup$

This gives the recently opened files as a list of rules:

Lookup[Options@$FrontEnd, NotebooksMenu]

Just the file names:

First /@ Lookup[Options@$FrontEnd, NotebooksMenu]

FileNameJoin instead of FrontEnd`FileName: (only tested on windows)

FileNameJoin[(Append @@ ((First@Last[#])[[;; 2]]))[[2 ;;]]] & /@ Lookup[Options@$FrontEnd, NotebooksMenu]
$\endgroup$
1
  • $\begingroup$ Works nicely. Lookup is new in 10 and this is the first time I have met it. Much simpler. Thanks $\endgroup$ – Hugh Apr 29 '16 at 14:20
10
$\begingroup$

Try

FE`Evaluate[FEPrivate`GetPopupList["MenuListNotebooksMenu"]]

It works in my machine :)

Then you may try something like this to open the notebooks:

ActionMenu["Open History", 
 Rest@FE`Evaluate[FEPrivate`GetPopupList["MenuListNotebooksMenu"]] /. 
  HoldPattern[a_ -> b_] :> (a :> NotebookOpen[$HomeDirectory <> b])]

Mathematica graphics


Edit

The following will open the notebooks, notwithstanding the directory where they are stored:

k[n_] := FrontEndExecute[FrontEndToken["OpenFromNotebooksMenu", n]]

ActionMenu["Open History", 
           MapIndexed[#1 :> Unevaluated@k@#2[[1]] &, 
           Reverse@Rest[FE`Evaluate[FEPrivate`GetPopupList["MenuListNotebooksMenu"]]]
                                                                         [[All, 1]]]]
$\endgroup$
4
  • $\begingroup$ @ belisarius thank you for this. This does not quite work for me because the notebook can be anywhere and starting from $HomeDirectory does not get the search going. Does Mathematica keeps a list of directories associated with the notebooks in the MenuList? A full search using FileNames from C:\\ takes a long time so I guess FileNames is not used. If you can point me in the correct direction for finding a file that would be kind otherwise thank you. $\endgroup$ – Hugh Jul 10 '15 at 20:24
  • $\begingroup$ @Hugh See the edit. please $\endgroup$ – Dr. belisarius Jul 11 '15 at 5:34
  • $\begingroup$ @ belisarius thank you again. Now it is working. How you know all these secret commands is a mystery to me. One more very picky point. The order is not the most recent on top but jumbled. The order is correct from "OpenFromNotebooksMenu" but somewhere an order change is happening. Can this be fixed? $\endgroup$ – Hugh Jul 11 '15 at 10:56
  • 1
    $\begingroup$ @hugh I reversed the order because the program code is a bit easier that way. I believe you can try to straighten that on your own, not a bad exercise. Regarding the "where I got to know this secret commands", the answer is of course "at this site" See for example here $\endgroup$ – Dr. belisarius Jul 11 '15 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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