正则表达式 – emacs组织模式,仅搜索标题
在emacs中,我希望只能搜索组织模式文件中的“标题”.
想法1:仅搜索可见 想法2:使用正则表达式 C-c / / //opens regex search *.*heading //start with * (escaped),followed by any chars,then heading. 但目前输入所有这些都很麻烦.考虑到我已经开始学习像3小时前的emacs,我能以某种方式自动化吗? 用例就是搜索我的笔记.有些像?7000行,我通常只搜索标题. [编辑解决方案1] 即,我安装了Melpa: 然后我从包列表中安装了helm: 然后我编辑了我的.emacs并绑定了一个热键: 我重新加载了emacs,现在当按下Ctrl =时会弹出一个可搜索的轮廓,当我输入其他字符时,它会自动缩小.通常的C-n,C-p按钮用于导航. 谢谢! [编辑解决方案2] ;; ——— WORF Utilities ——————————————————————————————————————————————————————————————— ;; https://github.com/abo-abo/worf/blob/master/worf.el (defun worf--pretty-heading (str lvl) "Prettify heading STR or level LVL." (setq str (or str "")) (setq str (propertize str 'face (nth (1- lvl) org-level-faces))) (let (desc) (while (and (string-match org-bracket-link-regexp str) (stringp (setq desc (match-string 3 str)))) (setq str (replace-match (propertize desc 'face 'org-link) nil nil str))) str)) (defun worf--pattern-transformer (x) "Transform X to make 1-9 select the heading level in `worf-goto'." (if (string-match "^[1-9]" x) (setq x (format "^%s" x)) x)) (defun worf-goto () "Jump to a heading with `helm'." (interactive) (require 'helm-match-plugin) (let ((candidates (org-map-entries (lambda () (let ((comp (org-heading-components)) (h (org-get-heading))) (cons (format "%d%s%s" (car comp) (make-string (1+ (* 2 (1- (car comp)))) ? ) (if (get-text-property 0 'fontified h) h (worf--pretty-heading (nth 4 comp) (car comp)))) (point)))))) helm-update-blacklist-regexps helm-candidate-number-limit) (helm :sources `((name . "Headings") (candidates .,candidates) (action . (lambda (x) (goto-char x) (call-interactively 'show-branches) (worf-more))) (pattern-transformer . worf--pattern-transformer))))) 然后将其绑定到热键: (global-set-key (kbd "<f3>") 'worf-goto)
来自
worf的worf-goto可以做到这一点, 从 helm起,也可以使用helm-org-in-buffer-headings. worf-goto实际上使用helm作为后端.除了helm-org-in-buffer-headings之外,您还可以: >标题的颜色与原始缓冲区中的颜色相同>您可以使用相应的数字选择具有相同级别的所有标题 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |