How to automatically evaluate certain lisp code after starting an emacsclient?

前端 未结 4 956

When starting Emacs, init.el (or .emacs.el) is evaluated. However, when starting emacsclient, no similar lisp code is evaluated.

How can I get a lisp file to be eval

相关标签:
4条回答
  • 2020-12-15 08:18

    If you really want new frame customizations, there's create-frame-hook which takes one arg (the new frame)...

    If you mean gnuclient, you can use the command-line option "-eval" to evaluate something (and then just make an alias to always eval your customizations).

    0 讨论(0)
  • 2020-12-15 08:24

    I use the following code to automatically change the behavior of server buffers. I use it especially with the Firefox extension It's All Text. In that extension, buffers are named according to the domain name, so you can figure out which rule to apply by using string-match to match the name of the file.

    (defun server-edit-presets ()
      (cond
       ;; When editing mail, set the goal-column to 72.
       ((string-match "mail\\.google\\.com\\.[0-9a-z]+\\.txt" (buffer-name))
        (longlines-mode-off)
        (auto-fill-mode 1)
        (set-fill-column 72)
        (save-excursion
          ;; Don't know if this is necessary, but it seems to help.
          (set-buffer (buffer-name))
          (goto-char (point-min))
          ;; Replace non-breaking strange space characters
          (while (search-forward (char-to-string 160) nil t)
            (replace-match " "))))))
    
    (add-hook 'server-visit-hook 'server-edit-presets)
    (add-hook 'server-visit-hook '(lambda () (longlines-mode 1)))
    
    0 讨论(0)
  • 2020-12-15 08:35

    You can add a function to the hook 'server-visit-hook, which is run every time the server is called (every time you call emacsclient).

    0 讨论(0)
  • 2020-12-15 08:38

    @LSW:

    Try 'window-setup-hook. This addresses the annoyance since it is called even if emacsclient is not passed a file.

    0 讨论(0)
提交回复
热议问题