文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>emacs中搜索值包含特定字符串的所有变量

emacs中搜索值包含特定字符串的所有变量

时间:2007-07-04  来源:hellwolf

在emacs中,有的扩展会自作主张的给你创建文件(夹),而你一时又不知道该用哪个变量控制,那么下面这个脚本可以帮上你的忙:

;;search variables by value
(defun my-search-variables-by-value (r)
(interactive "MSearch variable match this regex :")
(with-output-to-temp-buffer "*Help*"
(with-current-buffer (get-buffer "*Help*")
(princ "Variables value matches ")
(let ((p (point)))
(princ (format "%s :\n\n" r))
(add-text-properties
p (point)
(list
'face 'bold)))
(mapatoms
(lambda (s)
(if (and (boundp s)
(stringp (symbol-value s))
(string-match r (symbol-value s)))
(progn
(let ((p (point))
(map (make-sparse-keymap)))
(define-key map [mouse-1]
(lambda (event)
(interactive "e")
(save-excursion
(mouse-set-point event)
(describe-variable
(intern (get-text-property (point) 'symname))))))
(princ (symbol-name s))
(add-text-properties
p (point)
(list
'symname (symbol-name s)
'face 'button
'mouse-face 'highlight
'keymap map))
(princ "\n")
(princ (concat (symbol-value s) "\n\n"))
))))))
(help-setup-xref (list #'my-search-variables-by-value r)
(interactive-p))
(print-help-return-message)))
使用方法:
将上面的代码拷贝到你的dotEmacs
需要的时候输入M-x my-search-variables-by-value,然后按照提示输入一个regex即可在一个*Help* buffer中列出所有包含该regex的变量了。点击查看运行效果。
相关阅读 更多 +
排行榜 更多 +
一剑灭天

一剑灭天

角色扮演 下载
戮仙战纪

戮仙战纪

角色扮演 下载
头号海贼王手机版

头号海贼王手机版

棋牌卡牌 下载