小编use*_*576的帖子

在org-babel src块中缩进代码

在组织模式文件中,使用如下代码:

#+begin_src emacs-lisp
(add-to-list 'org-tab-before-tab-emulation-hook
             (lambda ()
               (when (within-the-body-of-a-begin-src-block)
                 (indent-for-tab-command--as-if-in-lisp-mode))))
#+end_src
Run Code Online (Sandbox Code Playgroud)

我希望TAB键缩进代码,如果它在lisp模式下的缓冲区中.

我需要的是:

  • 一种判断光标是否在src块内的方法.它不需要在标题行本身上触发,因为在这种情况下应该发生默认的组织折叠.
  • 一种根据标头中指定的模式(在本例中为emacs-lisp)缩进代码的方法.

Org已经可以根据模式突出显示src块语法,并且TAB挂钩就在那里.这看起来很可行.

emacs org-mode org-babel

13
推荐指数
3
解决办法
6787
查看次数

http.Handle(Handler或HandlerFunc)

如何实现以下功能?

func handle(pattern string, handler interface{}) {
    // ... what goes here? ...
    http.Handle(pattern, ?)
}

handle("/foo", func(w http.ResponseWriter, r http.Request) { io.WriteString(w, "foo") }
handle("/bar", BarHandler{})
Run Code Online (Sandbox Code Playgroud)

handle()传递一个匹配http.HandlerFunc类型的函数或一个实现http.Handler接口的类型.

reflection interface http go

5
推荐指数
1
解决办法
3017
查看次数

标签 统计

emacs ×1

go ×1

http ×1

interface ×1

org-babel ×1

org-mode ×1

reflection ×1