- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的大部分书签都以字母为前缀
第一个字母几乎总是唯一地确定书签。
例如,我可以通过这种方式,
使用 M-x bookmark-jump RET s RET 跳转到我的源文件夹(标记为“s:源”)。
我把它放在一个快捷方式上,所以它实际上是 ~ s RET。
我想最终摆脱 RET,
即得到 M-x bookmark-quick-jump RET s 或 ~ s
做上述工作。
我还希望它回退到默认行为:向我显示所有书签
以给定的字母开头,以防只有一个变体。
到目前为止,我有:
(defun bookmark-do-quick-jump (str)
(let ((completions (all-completions str bookmark-alist)))
(bookmark-jump
(if (eq 1 (length completions))
(car completions)
(completing-read "Jump to bookmark: " bookmark-alist nil t str)))))
还有两个小问题:
(setq bookmark-quick-jump-map
(let ((map (make-sparse-keymap)))
(mapcar (lambda (key)
(define-key map key
(lambda()
(interactive)
(bookmark-do-quick-jump key))))
(loop for c from ?a to ?z
collect (string c)))
map))
其次,当我打电话时
(bookmark-do-quick-jump "o")
它带有 3 个变体(org-capture-last-stored、org-capture-last-stored-marker...)。
completing-read
切换解决了第二件事至
ido-completing-read
:
(defun bookmark-do-quick-jump (str)
(let ((completions (all-completions str bookmark-alist)))
(bookmark-jump
(if (eq 1 (length completions))
(car completions)
(ido-completing-read "Jump to bookmark: " completions nil t str)))))
顺便说一句,我忘了提到我使用
bookmark+
.我不确定是否跳到 dired
bookmark-jump
.
最佳答案
我们可以重新映射 self-insert-command
在完成读取期间触发自动完成和自动接受行为。
我原来用的(or (minibuffer-complete-and-exit) (minibuffer-completion-help))
乍一看效果很好,但正如评论中所指出的那样,当一个书签的名称是另一个书签的前缀时,它就不那么理想了,因为它会立即接受较短的名称,从而使较长的名称无法访问。
调用 minibuffer-complete
和 minibuffer-completion-help
然而,一起破坏了完成功能,所以我复制了 minibuffer-complete-and-exit
的相关部分。到一个新功能。使用它可以解决所有早期的问题。
(require 'bookmark)
(defvar bookmark-do-quick-jump-map (copy-keymap minibuffer-local-must-match-map)
"Keymap for `bookmark-do-quick-jump'.
`minibuffer-local-must-match-map' is used by `completing-read' when its
REQUIRE-MATCH argument is t.
In `bookmark-do-quick-jump' we bind this modified copy to use in its place.")
(define-key bookmark-do-quick-jump-map
[remap self-insert-command] 'my-self-insert-complete-and-exit)
(defun bookmark-do-quick-jump ()
"Jump to specified bookmark with auto-completion and auto-acceptance."
(interactive)
(bookmark-maybe-load-default-file)
(let ((minibuffer-local-must-match-map bookmark-do-quick-jump-map))
(bookmark-jump
(completing-read "Jump to bookmark: " bookmark-alist nil t))))
(defun my-self-insert-complete-and-exit (n)
"Insert the character, then attempt to complete the current string,
automatically exiting when only one option remains, and displaying the
completion options otherwise."
(interactive "p")
(self-insert-command n)
(my-minibuffer-complete)
(let ((my-completions (completion-all-sorted-completions)))
(if (and my-completions (eq 0 (cdr my-completions)))
(exit-minibuffer)
(minibuffer-completion-help))))
(defun my-minibuffer-complete ()
"Copied from `minibuffer-complete-and-exit'."
(interactive)
(condition-case nil
(completion--do-completion nil 'expect-exact)
(error 1)))
(require 'bookmark)
(require 'ido)
(defvar bookmark-ido-quick-jump-map (copy-keymap minibuffer-local-map)
"Keymap for `bookmark-ido-quick-jump'.
Every time `ido-completing-read' is called it re-initializes
`ido-common-completion-map' and sets its parent to be `minibuffer-local-map'.
In `bookmark-ido-quick-jump' we provide this modified copy as a replacement
parent.")
(define-key bookmark-ido-quick-jump-map
[remap self-insert-command] 'my-self-insert-and-ido-complete)
(defun bookmark-ido-quick-jump ()
"Jump to selected bookmark, using auto-completion and auto-acceptance."
(interactive)
(bookmark-maybe-load-default-file)
(let ((minibuffer-local-map bookmark-ido-quick-jump-map)
(ido-enable-prefix t))
(bookmark-jump
(ido-completing-read "Jump to bookmark: "
(loop for b in bookmark-alist collect (car b))))))
(defun my-self-insert-and-ido-complete (n)
"Insert the character, then attempt to complete the current string,
automatically exiting when only one option remains."
(interactive "p")
(self-insert-command n)
;; ido uses buffer-local pre- and post-command hooks, so we need to
;; co-operate with those. We append our post-command function so that
;; it executes after ido has finished processing our self-insert.
(add-hook 'post-command-hook
'my-self-insert-and-ido-complete-post-command t t))
(defun my-self-insert-and-ido-complete-post-command ()
(remove-hook 'post-command-hook
'my-self-insert-and-ido-complete-post-command t)
;; Now that ido has finished its normal processing for the current
;; command, we simulate a subsequent `ido-complete' command.
(ido-tidy) ;; pre-command-hook
(ido-complete)
(ido-exhibit)) ;; post-command-hook
关于Emacs 更快的书签跳转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17496021/
我正在尝试创建一个在线书签系统。我已经设法从用户那里获取 URL 并将其存储到数据库中。但我也想采用“标题和标签”谁能帮我编写代码.. function add_bm($new_url) {
我目前正在开发一个动态使用数据库的应用程序。 这意味着它被设计为可以在任何时间、任何结构上与任何数据库一起使用。 我担心的是,我希望对某些记录进行“标记”或添加书签,因此我需要使用 Filter 属性
我正在创建一些许多人称之为书签栏的东西,但在网站本身内。基本上我有一个常规的 Bootstrap navbar很少有菜单项上有“图钉”。通过按图钉,用户可以固定该菜单项以快速访问我创建的侧边栏。 现在
我最近在聊天部分了解到,如果使用书签,则可以渲染 LaTeX: http://meta.math.stackexchange.com/a/3297 stackexchange 站点都渲染代码像这样。
我有这个可爱的 javascript 书签... javascript:var nam="blablabla&name"; var els=document.getElementsByName
我经常使用网页的三种变体,1) 开发网址,2) 预览/暂存网址,以及 3) 实时网址。 我想创建一个链接(小书签?)然后我可以添加到我的书签栏,这将更改部分 URL 字符串(基本上是页面名称),然后将
这个问题在这里已经有了答案: Add to browser favorites/bookmarks from JavaScript but for all browsers (mine doesn'
我正在尝试编写一个小书签来检测用户是否在已解析的页面上,如果他不在,则应将值传递给 API。 if (window.location.indexOf("thequeue.org") >= 0) {
有没有人知道为什么下面的 JavaScript 代码在 Firefox 上没有任何问题,并且在 IE7 上也能正常工作,但在 IE8 上却不行了?我不知道,我很感激任何提示:-) 我已将该代码作为收藏
一个页面中有很多链接,我需要快速单击其中包含文本“删除”的链接。这会导致 AJAX 请求,因此需要稍微暂停一下。什么是 JavaScript 书签代码(没有库,例如 jQuery),它将快速调用直接作
我需要一个可以单击按钮的 JavaScript 书签。问题是,页面上有 100 多个按钮,它们的值都相同。名字很独特,但是很长。 元素的全名类似于: actions[http://apps.faceb
我在制作 javascript 书签时遇到了问题,其中的代码同时包含 "" 引号和 '' 引号。举例来说,我的代码如下, Temporary HTML Doc
希望大家帮帮我。我似乎无法弄清楚如何制作一个小书签来选择网页下拉菜单中的选项。 希望实现:在我的chrome浏览器上做一个书签。当我在此页面上单击它时,它将选择下拉列表并在成员框中选择级别 2 网页的
当我浏览文件系统时,我设法在一个窗口中完成了繁琐的工作。 改善人体工程学,我决定为我最常用的目录创建书签,其短名称如:'lwt'、'eve' 等。但每次打开书签时,都会创建新的目录缓冲区,即使旧缓冲区
我正在努力了解 HATEOAS。 让我们通过一个例子来工作。客户端将浏览器加载到 getemails.com。为简单起见,让我们假设对 getemails.com 的调用访问了服务器并返回一个电子邮件
我想每周在 Safari 中备份一次。告诉我如何使用终端命令导出书签?谢谢你。 最佳答案 plutil -convert xml1 -o ~/Desktop/SafariBookmarks.xml ~
我想知道我们如何从 Mac OS X 上的另一个 Cocoa 应用程序访问 Safari 书签,以一种对 future 安全的方式。 您可能知道,检索 Safari 书签的常见机制有两种: 要么阅读
有谁知道如何通过 SDK 以编程方式访问“ map ”应用程序的书签?如果可能的话,我想阅读和书写书签。有想法吗? 谢谢! 最佳答案 我很确定答案是否定的。我考虑了两种可能的解决方案: 您可以直接访问
谁能告诉我怎么转 Top 又名页面顶部链接到书签。 不太了解 JavaScript,无法实现我想要的效果。 或者,如果我使用了错误的代码,那么你能不能帮我修好它,然后把它变成小书签。 最佳答案 创建
如何在vim中设置书签?我想为一些行和函数添加书签。你如何在代码上做书签?我的代码是用 C 编写的。 最佳答案 如果您输入 ma ,它将在当前位置的当前行上创建书签,名称为 a . 例如,键入 ma在
我是一名优秀的程序员,十分优秀!