emacsmenuflyspell

How to limit the number of "suggestions" that flyspell gives?


In emacs flyspell mode, sometimes the list of suggestions is really long, so that the pop-up menu is taller than the screen and requires vertical scrolling of the menu because the "Save word" option is at the bottom of the menu.

Is there a way to to do one of the following:

  1. Move "Save word" to the top of the menu?
  2. Put a hard limit on the number of suggestions displayed?
  3. Modify the threshold of a matching word?

Solution

  • This code will limit all ispell solutions to a maximum of limit-ispell-choices-to, which gets the desired limit in 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)))))