Emacs模式为Stack Overflow的降价 [英] Emacs mode for Stack Overflow's markdown

查看:137
本文介绍了Emacs模式为Stack Overflow的降价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Emacs中使用组织模式来处理我的所有技术文档。我想使用Emacs准备堆栈溢出的问题。有没有Emacs模式,甚至更好的是Org模式的扩展来处理堆栈溢出格式?理想情况下,它应该包括Stack Overflow问题/注释缓冲区中使用的所有格式化选项。

解决方案

将Emacs与堆栈溢出



。有了它,您可以在您的Org模式缓冲区中包含一些降价模式,您可以通过markdown模式进行编辑。您可以使用以下内容:


  1. 在组织模式缓冲区中输入< s ,然后按 Tab 。这将导致

     #+ begin_src 

    #+ end_src


  2. 输入 markdown after #+ begin_src ,以便您有

     #+ begin_src markdown 

    #+ end_src


  3. 在源块内部(#+ begin_src markdown #+ end_src )按 Cc'使用markdown-mode编辑源块。


  4. 以markdown-mode编辑源块。


  5. Cc'返回到组织模式缓冲区并插入编辑。这可能看起来像下面的截图显示:





I am using Org-mode in Emacs to handle all my technical documentation. I would like to use Emacs to prepare questions that I have for Stack Overflow. Is there an Emacs mode for that, or even better, an extension for Org-mode to handle Stack Overflow formatting? Ideally it should include all formatting options supported by the markdown syntax used in the Stack Overflow question/comment buffers.

解决方案

Integrating Emacs with Stack Overflow

As mentioned you can use markdown-mode. To integrate markdown-mode with Stack Overflow you can use the Firefox plugin It's All Text which lets you edit textareas with an external editor. Here is how to set it up:

  1. Install markdown-mode. If you use Debian or Ubuntu you can install it by issuing

    sudo apt-get install emacs-goodies-el
    

    or if you're on emacs 24 (or have package.el on emacs 23) and Marmalade or Melpa you can install it with

    M-x package-install RET markdown-mode
    

  2. Install It's All Text.

  3. Set It's All Text's preferences to use Emacs. Either you can set it to the executable (e.g. /usr/bin/emacs) or the emacsclient.
  4. Add the following to your .emacs to enable markdown-mode for Stack Overflow and Stack Exchange textareas:

    ;; Integrate Emacs with Stack Exchange https://stackoverflow.com/a/10386560/789593
    (add-to-list 'auto-mode-alist '("stack\\(exchange\\|overflow\\)\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))
    

    Alternatively, if as-external-alist is defined—if M-x describe-variable RET as-external-alist doesn't fail—it will probably override your auto-mode-alist. It has a slightly different format (it's a list of pairs instead of a list of cons cells) so this will work:

    (add-to-list 'as-external-alist '("stack\\(exchange\\|overflow\\)\\.com\\.[a-z0-9]+\\.txt" markdown-mode))
    

  5. Press the blue edit button at the bottom right side of a textarea to edit it via emacs. The blue edit button is shown in the following screenshot:

    In the following screenshot is an Emacs buffer in markdown-mode editing this post:

  6. When you are done editing in Emacs save the buffer to send it to Firefox.

If you want this functionality for other domains you need to change the regexp above. The following recognizes Stack Exchange, Stack Overflow, Ask Ubuntu and Super User:

;; Integrate Emacs with Stack Exchange https://stackoverflow.com/a/10386560/789593
(add-to-list 'auto-mode-alist '("\\(stack\\(exchange\\|overflow\\)\\|superuser\\|askubuntu\\)\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))

Using markdown-mode with Org-mode

To use markdow-mode with Org-mode you can use its feature for working with source code. With it you can include blocks of markdown inside your Org-mode buffers which you can edit via markdown-mode. You can use it as follows:

  1. When in an Org-mode buffer enter <s on a newline and press Tab. This will result in

    #+begin_src 
    
    #+end_src
    

  2. Enter markdown after #+begin_src so that you have

    #+begin_src markdown
    
    #+end_src
    

  3. When inside the source block (between #+begin_src markdown and #+end_src) press C-c ' to edit the source block with markdown-mode.

  4. Edit the source block in markdown-mode.

  5. Press C-c ' to return to the Org-mode buffer and insert the edit. This can look like what the following screenshot shows:

这篇关于Emacs模式为Stack Overflow的降价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆