diff --git a/etc/init.lisp b/etc/init.lisp index c481d49..974223e 100644 --- a/etc/init.lisp +++ b/etc/init.lisp @@ -395,6 +395,8 @@ (define-key "n" #'thread-search-next-unread-message *thread-keymap*) +(define-key "C-u" #'thread-search-next-undeleted-message *thread-keymap*) + (define-key "r" #'reply-message *thread-keymap*) (define-key "right" #'open-next *thread-keymap*) diff --git a/src/db.lisp b/src/db.lisp index 62795d7..9ad928d 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -2497,6 +2497,24 @@ to `timeline' , `folder' and possibly `account-id', older than (order-by= query :message-index) (fetch-single query))) +(defun search-next-undeleted-message (timeline + folder + start-status-message-index + &key (account-id nil)) + "Search the next undeleted message belonging +to `timeline' , `folder' and possibly `account-id', older than +`start-status-message-index'" + (let* ((query (make-filtered-message-select nil + timeline + folder + account-id + `(:and :> :status.message-index + ,start-status-message-index) + `(:and := :status.deletedp + ,+db-false+)))) + (order-by= query :message-index) + (fetch-single query))) + (defmacro with-add-account-id-to-query ((query query-body) account-id &body body) `(let ((,query ,query-body)) (when ,account-id diff --git a/src/package.lisp b/src/package.lisp index 8a09650..4c3b421 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1087,6 +1087,7 @@ :search-next-message-meta :search-previous-message-meta :search-next-unread-message + :search-next-undeleted-message :last-message-index-status :last-status-id-timeline-folder :first-status-id-timeline-folder @@ -2495,6 +2496,7 @@ :search-next-message-meta :search-previous-message-meta :search-next-unread + :search-next-undeleted :add-mention :remove-mention :goto-message @@ -3048,6 +3050,7 @@ :thread-search-previous-message-meta :repeat-search :thread-search-next-unread-message + :thread-search-next-undeleted-message :thread-open-selected-message :thread-mark-delete-selected-message :thread-mark-prevent-delete-selected-message diff --git a/src/thread-window.lisp b/src/thread-window.lisp index cebb1c0..71cac6b 100644 --- a/src/thread-window.lisp +++ b/src/thread-window.lisp @@ -1052,7 +1052,7 @@ db:renumber-timeline-message-index." (timeline-folder timeline-folder) (timeline-type timeline-type)) object (a:when-let* ((selected-fields (selected-row-fields object)) - (starting-index (db-utils:db-getf selected-fields :message-index))) + (starting-index (db-utils:db-getf selected-fields :message-index))) (let ((matching-status (db:search-next-unread-message timeline-type timeline-folder starting-index))) @@ -1062,6 +1062,22 @@ db:renumber-timeline-message-index." (open-message object)) (ui:info-message (_ "No others unread messages exist"))))))) +(defmethod search-next-undeleted ((object thread-window)) + (with-accessors ((row-selected-index row-selected-index) + (rows rows) + (timeline-folder timeline-folder) + (timeline-type timeline-type)) object + (a:when-let* ((selected-fields (selected-row-fields object)) + (starting-index (db-utils:db-getf selected-fields :message-index))) + (let ((matching-status (db:search-next-undeleted-message timeline-type + timeline-folder + starting-index))) + (if matching-status + (let ((new-message-index (db:row-message-index matching-status))) + (rebuild-lines object new-message-index) + (open-message object)) + (ui:info-message (_ "No others undeleted messages exist"))))))) + (defmethod add-mention ((object thread-window) mention) (with-accessors ((mentions mentions)) object (let ((reversed (reverse mentions))) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 75530ac..c5208f3 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -343,6 +343,10 @@ Metadata includes: "Jump to next unread message" (thread-window:search-next-unread *thread-window*)) +(defun thread-search-next-undeleted-message () + "Jump to next undeleted message" + (thread-window:search-next-undeleted *thread-window*)) + (defun repeat-search () "Repeat the last search performed" (push-event (make-instance 'search-next-event