Configure emacs variables for a specific function

I run the mail client in a separate emacs window (usually connecting to gnuserv), for example,

emacs -f wl 

(the email client is Wanderlust, which probably doesn't matter much).

Is it possible for emacs to remember my preferred

  • window layout
  • dimensions of the main window,
  • fonts, colors, etc.,

to install them only when calling wl ? Roughly speaking, if I want to have a black background in the mail client, but white otherwise?

I am particularly interested in saving the window layout, because by default I need to configure it manually every time wl loads.

+4
source share
2 answers

There is a variable default-frame-alist that allows you to specify the default appearance and behavior for the new frame (a frame is what you call a separate Emacs window). Although it overrides the settings for the entire frame, you can tell your function to mask its global value and set it. Something like that:

 (defadvice wl (around wl-frame-settings activate) (let ((default-frame-alist (append '((width . 82) (height . 36) (cursor-color . "#ffa200") (tool-bar-lines . 0) ;; ... ) default-frame-alist))) ad-do-it)) 

As TJ pointed out, this solution may have a flaw that causes too late. TJ wlwrapper might be the best way.

+3
source

Based on the Török Gábor answer , you can use any of several packages to store and restore window / frame configurations, many of which are listed here . Different window layout packages have their own quirks, so you will need to find what you like (so many b / c packages that everyone finds something they don't like in existing packages and rolls them back).

As for fonts and colors, some can be adjusted frame by frame, see the information page for frame options .

As for how to connect it to the 'wl function, you can use the tip if you want (I like to use it), but it would be much simpler to either directly configure 'wl itself or write a shell that loads the frame / window configuration, and then calls 'wl . Then your call may change to:

 emacs -f wlwrapper 

How emacsclient is configured (or, for older Emacsen, gnuclient ) may be the reason that the TG solution does not work. Perhaps I used the solution 'wlwrapper , setting up emacsclient to reuse an existing frame, then inside 'wlwrapper change the call to 'default-frame-parameters and then 'wl . This way you ensure the creation of a frame after the parameters.

Something like this is untested:

 (defun wlwrapper () "wrapper for 'wl which sets up window/frame configurations" (let ((default-frame-alist (append '((width . 82) (height . 36) (cursor-color . "#ffa200") (tool-bar-lines . 0) ;; ... ) default-frame-alist))) ;; if 'wl doesn't create a frame (select-frame (make-frame)) (wl) ;; now use which ever window saving package you want )) 
+3
source

Source: https://habr.com/ru/post/1285796/


All Articles