在emacs flyspell模式下,有时建议列表很长,因此弹出菜单比屏幕高,需要垂直滚动菜单,因为“保存字”选项位于菜单的底部
有没有办法执行以下操作之一:
答案 0 :(得分:1)
此代码会将所有ispell解决方案限制为最大limit-ispell-choices-to
,这会在flyspell
中获得所需的限制。
(defvar limit-ispell-choices-to 5
"Number indicating the maximum number of choices to present")
(defadvice ispell-parse-output (after limit-ispell-choices activate)
(when (and (listp ad-return-value)
ad-return-value)
(let* ((miss-list-end (nthcdr (- limit-ispell-choices-to 1)
(nth 2 ad-return-value)))
(guess-list-end (nthcdr (- limit-ispell-choices-to 1)
(nth 3 ad-return-value))))
(when miss-list-end (setcdr miss-list-end nil))
(when guess-list-end (setcdr guess-list-end nil)))))
答案 1 :(得分:0)
这会将“保存字”放在顶部。我刚刚在源代码中交换了两个单词。 这有点像黑客,但我看不到更好的方法。
(defun flyspell-emacs-popup (event poss word)
"The Emacs popup menu."
(unless window-system
(error "This command requires pop-up dialogs"))
(if (not event)
(let* ((mouse-pos (mouse-position))
(mouse-pos (if (nth 1 mouse-pos)
mouse-pos
(set-mouse-position (car mouse-pos)
(/ (frame-width) 2) 2)
(mouse-position))))
(setq event (list (list (car (cdr mouse-pos))
(1+ (cdr (cdr mouse-pos))))
(car mouse-pos)))))
(let* ((corrects (if flyspell-sort-corrections
(sort (car (cdr (cdr poss))) 'string<)
(car (cdr (cdr poss)))))
(cor-menu (if (consp corrects)
(mapcar (lambda (correct)
(list correct correct))
corrects)
'()))
(affix (car (cdr (cdr (cdr poss)))))
show-affix-info
(base-menu (let ((save (if (and (consp affix) show-affix-info)
(list
(list (concat "Save affix: " (car affix))
'save)
'("Accept (session)" session)
'("Accept (buffer)" buffer))
'(("Save word" save)
("Accept (session)" session)
("Accept (buffer)" buffer)))))
(if (consp cor-menu)
(append save (cons "" cor-menu))
save)))
(menu (cons "flyspell correction menu" base-menu)))
(car (x-popup-menu event
(list (format "%s [%s]" word (or ispell-local-dictionary
ispell-dictionary))
menu)))))