Position view for the best article visibility in the buffer.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Fri, 02 Apr 2021 18:05:36 +0300
changeset 1294 3940e242e941
parent 1293 d6aa9445a749
child 1295 401e72093661
Position view for the best article visibility in the buffer.
misc/gadict.el
--- a/misc/gadict.el	Thu Apr 01 23:13:47 2021 +0300
+++ b/misc/gadict.el	Fri Apr 02 18:05:36 2021 +0300
@@ -320,7 +320,8 @@
 definition. Check for headwords ordering during search."
   (interactive (list (read-string "Headword: " nil 'gadict--headword-history)))
   (gadict-search-floor headword)
-  (recenter))
+  ;; Position view for the best article visibility in the buffer.
+  (recenter 1))
 
 (defun gadict-insert-article-in-order ()
   "Insert new article template with respect of headword order."
@@ -329,8 +330,9 @@
     (setq headword (read-string "Headword: " nil 'gadict--headword-history))
     (unless (gadict-search-floor headword)
       (setq pos (completing-read "POS: " gadict--pos nil t nil 'gadict--pos-history))
-      (gadict-insert-article headword pos)
-      (recenter))))
+      (gadict-insert-article headword pos))
+    ;; Position view for the best article visibility in the buffer.
+    (recenter (+ scroll-margin 2))))
 
 (defun gadict--find-headword-end ()
   (save-excursion