contrib/gadict.el
changeset 440 fb584cf490db
parent 435 ca2c73d8698f
child 444 70fa100cedef
equal deleted inserted replaced
439:20e2e561fb14 440:fb584cf490db
   137     (insert headword)
   137     (insert headword)
   138     (insert "\n  []")
   138     (insert "\n  []")
   139     (backward-char)))
   139     (backward-char)))
   140 
   140 
   141 (defun gadict-search-floor (headword)
   141 (defun gadict-search-floor (headword)
   142   "Move to HEADWORD definition or place before definition should
   142   "Move to HEADWORD definition or place on posiiton for new corresponding
   143 be placed. Check for headwords ordering during search.
   143 definition. Check for headwords ordering during search.
   144 
   144 
   145 Return `t' if definition found, `nil' if no such headword."
   145 Return `t' if definition found, `nil' if no such headword."
   146   (interactive (list (read-string "Headword: ")))
   146   (interactive (list (read-string "Headword: ")))
   147   (let ( prev curr )
   147   (let ( prev curr )
   148     (catch 'exit
   148     (catch 'exit
   152       (forward-line 2)
   152       (forward-line 2)
   153       (setq prev (buffer-substring-no-properties (point) (line-end-position)))
   153       (setq prev (buffer-substring-no-properties (point) (line-end-position)))
   154       (when (string= headword prev)
   154       (when (string= headword prev)
   155         (throw 'exit t))
   155         (throw 'exit t))
   156       (when (string< headword prev)
   156       (when (string< headword prev)
       
   157         (goto-char (point-min))
   157         (throw 'exit nil))
   158         (throw 'exit nil))
   158       (while t
   159       (while t
   159         (unless (re-search-forward "^__$" nil t)
   160         (unless (re-search-forward "^__$" nil t)
   160           (throw 'exit nil))
   161           (throw 'exit nil))
   161         (forward-line 2)
   162         (forward-line 2)