怎样在 Emacs 中编辑任意文字区域: Difference between revisions

From 清冽之泉
Jump to navigation Jump to search
Created page with "<syntaxhighlight lang="bash"> sudo touch /etc/systemd/system/emacs-sudo.service sudo chmod 664 /etc/systemd/system/emacs-sudo.service </syntaxhighlight> <syntaxhighlight lang="bash"> [Unit] Description=Emacs: the extensible, self-documenting text editor [Service] Type=forking ExecStart=/usr/bin/emacs --daemon ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)" Environment=SSH_AUTH_SOCK=%t/keyring/ssh Restart=always [Install] WantedBy=multi-user.target </syntaxhighlight>..."
 
No edit summary
 
Line 1: Line 1:
<syntaxhighlight lang="bash">
# 在 Firefox 中,安装 <code> Edit with Emacs </code> 拓展
sudo touch /etc/systemd/system/emacs-sudo.service
# 在 Emacs 中,用 package-list-packages 安装 <code> edit-server </code> 拓展
sudo chmod 664 /etc/systemd/system/emacs-sudo.service
# 在 Emacs 中,用 package-list-packages 安装 <code> use-package </code> 拓展
# 在 Emacs 配置文件中写下:
<syntaxhighlight lang="elisp" line>
(use-package edit-server
  :ensure t
  :commands edit-server-start
  :init (if after-init-time
              (edit-server-start)
            (add-hook 'after-init-hook
                      #'(lambda() (edit-server-start))))
  :config (setq edit-server-new-frame-alist
                '((name . "Edit with Emacs FRAME")
                  (top . 200)
                  (left . 200)
                  (width . 80)
                  (height . 25)
                  (minibuffer . t)
                  (menu-bar-lines . t))))
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang="bash">
即可。
[Unit]
Description=Emacs: the extensible, self-documenting text editor
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=always
[Install]
WantedBy=multi-user.target
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
sudo systemctl daemon-reload
sudo systemctl enable emacs.service
sudo systemctl start emacs.service
</syntaxhighlight>

Latest revision as of 10:21, 29 September 2025

  1. 在 Firefox 中,安装 Edit with Emacs 拓展
  2. 在 Emacs 中,用 package-list-packages 安装 edit-server 拓展
  3. 在 Emacs 中,用 package-list-packages 安装 use-package 拓展
  4. 在 Emacs 配置文件中写下:
(use-package edit-server
  :ensure t
  :commands edit-server-start
  :init (if after-init-time
              (edit-server-start)
            (add-hook 'after-init-hook
                      #'(lambda() (edit-server-start))))
  :config (setq edit-server-new-frame-alist
                '((name . "Edit with Emacs FRAME")
                  (top . 200)
                  (left . 200)
                  (width . 80)
                  (height . 25)
                  (minibuffer . t)
                  (menu-bar-lines . t))))

即可。