代码之家  ›  专栏  ›  技术社区  ›  Cheeso

emacs/elisp:哈希(磅、数字符号、octothorp)符号用于什么?

  •  83
  • Cheeso  · 技术社区  · 15 年前

    这是做什么的?

    (add-hook 'compilation-mode-hook #'my-setup-compile-mode)
    

    …它和

    (add-hook 'compilation-mode-hook 'my-setup-compile-mode)
    
    3 回复  |  直到 10 年前
        1
  •  81
  •   Mirzhan Irkegulov    10 年前

    没有区别:

    (eq 'my-add #'my-add)
    

    产量 t

    这个 # 可用于 lambda 向字节编译器指示可以对以下表达式进行字节编译的表达式,请参阅文档 Anonymous Functions . 但是在符号的情况下没有什么可编译的。

    一般来说,它用于 printed representation 与左尖括号(<)一起表示打印的对象是说明(但无法读取)。例如:

    #<buffer foo.txt>
    

    它也被读者用于表示圆形结构的构造中。查看文档 Read Syntax for Circular Objects .

    然后你就可以用它来表示 base for integers ,例如 #x2c -> 44 .

    当然还有更多。

        2
  •  23
  •   Iceland_jack    14 年前

    我在搜索hash在hacking时发现的内容中的含义时发现了这个问题

    (“-%-”0 3
    (HELP ECHO“鼠标悬停或显示本地帮助时显示为工具提示。”)
    < /代码> 
    
    

    这是用于字符串中的文本属性的格式

    这可以使用propertizefunction:创建。

    (propertize“hover over me!”)“恭喜!”)
    < /代码> 
    
    

    /P>”

    将与相同(“悬停在我上方!”0 14(帮助echo“恭喜!”)< /代码>:

    如果您使用的是字体锁定模式,则使用buffer substring命令可能会产生如下结果:

    (buffer substring 1 28);当前buffer中的前27个字符
    _
    0 3
    (字体化T面字体锁定注释分隔符面)
    3 27
    (字体化的T面字体锁定注释面)
    < /代码> 
    
    

    所以你可以创造出:

    #("-%-" 0 3 (help-echo "Display as tooltip when mouse hovers or with display-local-help."))

    哪种格式用于text properties in strings在哪里?

    • "-%-",要属性化的文本:一个破折号和一个%-construct这就产生了“足以填满模线其余部分的虚线”,从而产生了著名的Emacs。------.
    • 0,应用文本属性的第一个字符。
    • 3,应用文本属性的最后一个字符,整个“-%-”.
    • (help-echo "..."),属性和字符串作为其参数。

    可以使用propertize function:

    (propertize "Hover over me!" 'help-echo '"congratulations!")
    

    (insert (propertize

    会和#("Hover over me!" 0 14 (help-echo "Congratulations!")):

    Small example.

    如果您使用的是字体锁定模式,请使用buffer-substring命令可能会产生如下结果:

    (buffer-substring 1 28) ; First 27 characters in the current buffer
     ⇒ #(";; This buffer is for notes"
         0 3
         (fontified t face font-lock-comment-delimiter-face)
         3 27
         (fontified t face font-lock-comment-face))
    

    因此,您可以创建如下内容:

    Showing the corresponding propertize function for multiple properties.

        3
  •  20
  •   itsjeyd    10 年前

    应该是全面的列表可以在顶部找到 Emacs lisp reference index .

    编辑 :或者更方便,从Emacs内部:

    • M—X info 雷特 (打开信息浏览器)

    • D elisp 雷特 (打开elisp手册)

    • # 雷特 (列出 γ 在索引中)