I'm using Edit with Emacs to edit Stack Overflow and Stack Exchange sites.
Currently I'm doing it with this message ;-)

When I click on the button under the text area of Chrome browser, I get a new file opened on Emacs. Current file is named emacs.stackexchange.com/questions/ask, which is opened in Text mode. I change it to Markdown mode, that makes it more appropriate.

When I press save the file: C-x C-s, the text gets updated in the browser.
Check this question regarding if file is saved locally or not.
But the mode is changed back to Text mode.

Is there a way to open the buffer in Markdown mode? Is it possible to avoid the change in the mode, when saving the buffer?

1 Answer 1


Browsing through the source code of edit-server reveals that you can either customize edit-server-url-major-mode-alist or set the mode in edit-server-start-hook. Here's the example from the code:

;; Buffers are edited in `text-mode' by default; to use a different
;; major mode, change `edit-server-default-major-mode' or customize
;; `edit-server-url-major-mode-alist' to specify major modes based
;; on the remote URL:
;; (setq edit-server-url-major-mode-alist
;;       '(("github\\.com" . markdown-mode)))
;; Alternatively, set the mode in `edit-server-start-hook'. For
;; example:
;; (add-hook 'edit-server-start-hook
;;           (lambda ()
;;             (when (string-match "github.com" (buffer-name))
;;               (markdown-mode))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.