簡體   English   中英

在里面顯示括號 - Emacs

[英]Show Parentheses When Inside Them - Emacs

在 emacs 中,有一種模式show-paren-mode當光標位於另一個時,它會為相反的匹配括號show-paren-mode 我寫了一個例子來解釋show-paren-mode

( <-colored  colored-> )| <-cursor 

但是當光標不在括號上時它不起作用:

( <-not colored    cursor inside->|    not colored-> )

我怎樣才能啟用它? 我發現在 paredit 中執行 slurpage 和 barfage 時,我無法很好地跟蹤括號,因為除非我在它們上,否則它們不會被着色。

這是最佳的:

( <-colored    cursor inside->|    colored-> )

編輯:感謝@lawlist 的評論,我已經解決了這個問題。

這對我很有效(新的建議實現可能需要更新的 Emacs 版本(比 25?):

(define-advice show-paren-function (:around (fn) fix)
  "Highlight enclosing parens."
  (cond ((looking-at-p "\\s(") (funcall fn))
        (t (save-excursion
             (ignore-errors (backward-up-list))
             (funcall fn)))))

感謝lawlist的評論,我已將他對另一個問題的回答中代碼添加到我的 init 文件中。

它以彩虹圖案為每組匹配的括號着色。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM