2013-10-04 2 views
2

emacs flyspell 모드에서 가끔 제안 목록이 너무 길어서 팝업 메뉴가 화면보다 크고 "단어 저장"옵션이 메뉴의 맨 아래에 있기 때문에 메뉴를 수직으로 스크롤해야합니다.flyspell에서 제공하는 "제안"수를 제한하는 방법은 무엇입니까?

다음 중 하나를 수행 할 수있는 방법이 있나요 : 메뉴 상단에

  1. 이동 "저장 단어는?"
  2. 표시되는 제안 수를 엄격하게 제한 하시겠습니까?
  3. 일치하는 단어의 임계 값을 수정 하시겠습니까?

답변

1

이 코드는 flyspell에서 원하는 한계를 얻을 수 limit-ispell-choices-to의 최대, 모든 ispell로 솔루션을 제한합니다.

(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))))) 
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))))) 
관련 문제