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

前端 未结 4 984

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: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)))
    

提交回复
热议问题