7/5/2023 0 Comments Facemenu 3![]() Each applies to the text in the region if the mark is active, and to the next self-inserting character if the mark is inactive. ![]() "Arrange for the next self-inserted char to have face `face'.The following commands can be used to add or remove faces (see Faces). Here is an example, from standard library facemenu.el: (defun facemenu-set-self-insert-face (face) If I am guessing correctly about what you really want, then please consider editing your question to something like " Is there any way to run a hook function only once? In other words use add-hook in a context where you know that the function should be executed when the hook is run, and have the function itself remove itself from the hook, after the function does its thing. The conventional, and simple, answer to that question is for your function to remove itself from the hook, after carrying out the one-time action that you want. I'm guessing that you are looking for a way to execute that particular function only once, whenever the hook is run. I'm guessing that you are not really looking for a way to " execute the hook only once". (remove-hook 'after-make-frame-functions 'emacsclient-setup-theme-function))))) (puthash "term" nil myGraphicModeHash)))) (ter (gethash "term" myGraphicModeHash))) (let ((gui (gethash "gui" myGraphicModeHash)) (defun emacsclient-setup-theme-function (frame) Thanks again code: (setq myGraphicModeHash (make-hash-table :test 'equal :size 2)) (add-hook 'after-make-frame-functions 'emacsclient-setup-theme-function)įinally I have totally working code that solves the behavior seen in the partial solution, to achieve this I run the function once by mode (terminal or gui) when then pertinent emacsclient is started for first time, then remove the function from the hook because is no needed any more. (remove-hook 'after-make-frame-functions 'emacsclient-setup-theme-function))) ![]() If you reload manually the theme all works fine and that's the reason why this behavior does not appear when the function is called by the hook every time as in my initial configuration. After a lot of tests, I realized that the behavior depends on which emacsclient starts first, and after discard various things, I think that it is maybe related with the color palette that is loaded. But still has a problem, once you start a client session in the terminal, the GUI does not load the themes properly and vice-versa. I have now this code, thanks to the answer. Is there any way to execute this function only once or getting the same result without using the hook? The reason for this behavior is clear, the hook is run on the server and all of its clients are affected. Obviously that happens only on the emacs clients connected to the same emacs server. Even worse, in the terminal clients already opened the theme color get completely messed up. When a new emacsclient -c/t session is started the hook is executed not only in the new frame, but in all the previous existent frames (other emacsclient sessions) and it makes a very annoying visual effect (the themes are loaded again in all those frames). ![]() Specifically this is the code snippet that I use to make that (based in this SO answer): (if (daemonp) I'm using the after-make-frame-functions hook to load properly the themes in an emacs client/server configuration.
0 Comments
Leave a Reply. |