1
0
Fork 0

- made input command history less messy

- adding a sequence  of n equals entries count as  one (no duplicate
    entries on top of the history);
  - removed duplicate for gemini history URL.
This commit is contained in:
cage 2021-01-27 20:31:18 +01:00
parent 1710ac5b48
commit c66a71881e
3 changed files with 20 additions and 6 deletions

View File

@ -471,6 +471,8 @@ open-message-link-window.input.selected.foreground = #FFB200
# gemini browser
gemini.current.url.prefix = "🌍 "
gemini.link.scheme.gemini.prefix = "→ "
gemini.link.scheme.other.prefix = "➶ "

View File

@ -174,7 +174,9 @@ list af all possible candidtae for completion."
(defun make-complete-gemini-iri-fn (prompt)
(lambda (hint)
(when-let ((matched (remove-if-not (starts-with-clsr hint)
(funcall #'db:history-prompt->values prompt))))
(remove-duplicates (funcall #'db:history-prompt->values
prompt)
:test #'string=))))
(values matched (reduce-to-common-prefix matched)))))
(defun complete-chat-message (hint)

View File

@ -724,14 +724,24 @@ to the corresponding id in table +table-account+"
(when-let ((user (user-id->user user-id)))
(db-getf user :acct)))
(defun last-in-history (prompt)
(let* ((query (select (:*
(:as (fields (:max :id)) :max))
(from :input-history)
(where (:= :prompt prompt)))))
(fetch-single query)))
(defun insert-in-history (prompt input)
"insert an history entry with `prompt` and `input'"
(when (string-not-empty-p input)
(let* ((now (prepare-for-db (local-time-obj-now)))
(insert-query (make-insert :input-history
(:prompt :input :date-added)
(prompt input now))))
(query insert-query))))
(let* ((last-inserted (last-in-history prompt)))
(when (or (null last-inserted)
(not (string= input (getf last-inserted :input))))
(let* ((now (prepare-for-db (local-time-obj-now)))
(insert-query (make-insert :input-history
(:prompt :input :date-added)
(prompt input now))))
(query insert-query))))))
(defun next-in-history (min-id prompt)
"Return the history entry with prompt `prompt` and id that is greater