edict-lookup-selectionの挙動を変更する

xyzzyではC-c eなどでキャレット位置の単語で辞書を引けるのだが、その挙動がやや不満である。
というのも、単語の一番後ろにキャレットがあると、次の単語で調べてしまうのだ。
ちょっと調べるときに、単語を入力して検索、とやると別の単語が出てきてイラッとする。
そんな微妙な使いにくさを解消するために関数を書き換えてみた。

(defun edict-lookup-selection (fn)
  (save-excursion
    (unless (or (get-selection-type)
                (and (not (syntax-word-p (char-before (point))))
                     (syntax-word-p (char-after (point)))))
      (backward-word))
    (multiple-value-bind (start end)
        (get-selection-start-end)
      (if start
          (funcall fn start end)
        (edict-lookup-word fn)))))