怎样在 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
 
(4 intermediate revisions by the same user not shown)
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> use-package </code> 拓展
sudo chmod 664 /etc/systemd/system/emacs-sudo.service
# 在 Emacs 配置文件中写下:
</syntaxhighlight>
<syntaxhighlight lang="elisp" line>
;;; init-edit-textarea-with-emacs.el -*- lexical-binding: t -*-
;;; 在 Mediawiki 的任意输入框,用 Emacs 编辑
;;; 与 emacsclient 的 server-start 没有关系,只是名字相似
;;;  https://github.com/stsquad/emacs_chrome
 
(use-package mediawiki-mode ;; 声明我要管理名为 foo 的 Emacs feature;至于它该从哪个 package 安装,可以由 :ensure 另行指定。
  :ensure mediawiki
  :commands mediawiki-mode)
 
(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-url-major-mode-alist
        '(("qingliezhiquan\\.com" . mediawiki-mode)))
  (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))))
 
(provide 'init-edit-textarea-with-emacs)


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


<syntaxhighlight lang="bash">
即可。
sudo systemctl daemon-reload
sudo systemctl enable emacs.service
sudo systemctl start emacs.service
</syntaxhighlight>

Latest revision as of 22:17, 20 July 2026

  1. 在 Firefox 中,安装 Edit with Emacs 拓展
  2. 在 Emacs 中,用 package-list-packages 安装 use-package 拓展
  3. 在 Emacs 配置文件中写下:
;;; init-edit-textarea-with-emacs.el -*- lexical-binding: t -*-
;;; 在 Mediawiki 的任意输入框,用 Emacs 编辑
;;; 与 emacsclient 的 server-start 没有关系,只是名字相似
;;;  https://github.com/stsquad/emacs_chrome

(use-package mediawiki-mode ;; 声明我要管理名为 foo 的 Emacs feature;至于它该从哪个 package 安装,可以由 :ensure 另行指定。
  :ensure mediawiki
  :commands mediawiki-mode)

(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-url-major-mode-alist
        '(("qingliezhiquan\\.com" . mediawiki-mode)))
  (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))))

(provide 'init-edit-textarea-with-emacs)

即可。