@@ -533,39 +533,70 @@ Useful if sending a request failed, perhaps from failed connectivity."
533
533
(set-window-configuration window-config))))))
534
534
535
535
(defun chatgpt-shell-prompt-compose-next-item ()
536
- " Jump to and select next item (block, link, interaction)."
536
+ " Jump to and select next item (request, response, block, link, interaction)."
537
537
(interactive )
538
538
(unless (derived-mode-p 'chatgpt-shell-prompt-compose-mode )
539
539
(user-error " Not in a shell compose buffer" ))
540
- (let* ((next-block (save-excursion
540
+ (let* ((request (save-excursion
541
+ (when (get-text-property (point ) 'ignore )
542
+ (text-property-search-forward 'request t )
543
+ (point ))))
544
+ (response (save-excursion
545
+ (when (get-text-property (point ) 'request )
546
+ (text-property-search-forward 'request nil )
547
+ (point ))))
548
+ (next-block (save-excursion
541
549
(call-interactively #'chatgpt-shell-next-source-block )))
542
550
(next-link (save-excursion
543
551
(call-interactively #'chatgpt-shell-next-link )))
544
552
(positions (delq nil (list next-block
545
- next-link)))
553
+ next-link
554
+ response
555
+ request)))
546
556
(next-pos (when positions
547
557
(apply 'min positions))))
548
558
(cond ((not next-pos)
549
559
(chatgpt-shell-prompt-compose-next-interaction))
560
+ ((eq next-pos request)
561
+ (deactivate-mark )
562
+ (goto-char next-pos))
550
563
((eq next-pos next-block)
551
564
(deactivate-mark )
552
565
(goto-char next-block)
553
566
(call-interactively #'chatgpt-shell-mark-block ))
567
+ ((eq next-pos response)
568
+ (deactivate-mark )
569
+ (goto-char next-pos))
554
570
((eq next-pos next-link)
555
571
(deactivate-mark )
556
572
(goto-char next-link)))))
557
573
558
574
(defun chatgpt-shell-prompt-compose-previous-item ()
559
- " Jump to and select previous item (block, link, interaction)."
575
+ " Jump to and select previous item (request, response, block, link, interaction)."
560
576
(interactive )
561
577
(unless (derived-mode-p 'chatgpt-shell-prompt-compose-mode )
562
578
(user-error " Not in a shell compose buffer" ))
563
- (let* ((previous-block (save-excursion
579
+ (let* ((location (point ))
580
+ (response (save-excursion
581
+ (when (and (not (get-text-property (point ) 'ignore ))
582
+ (not (get-text-property (point ) 'request )))
583
+ (text-property-search-backward 'request nil )
584
+ (text-property-search-forward 'request nil )
585
+ (unless (eq location (point ))
586
+ (point )))))
587
+ (request (unless response
588
+ (save-excursion
589
+ (goto-char (point-min ))
590
+ (text-property-search-forward 'prompt t )
591
+ (point ))))
592
+ (previous-block (save-excursion
564
593
(call-interactively #'chatgpt-shell-previous-source-block )))
565
594
(previous-link (save-excursion
566
595
(call-interactively #'chatgpt-shell-previous-link )))
567
596
(positions (delq nil (list previous-block
568
- previous-link)))
597
+ previous-link
598
+ response
599
+ request)))
569
600
(previous-pos (when positions
570
601
(apply 'max positions))))
571
602
(cond ((eq (point ) (save-excursion
@@ -574,6 +605,9 @@ Useful if sending a request failed, perhaps from failed connectivity."
574
605
(point )))
575
606
(deactivate-mark )
576
607
(chatgpt-shell-prompt-compose-previous-interaction))
608
+ ((eq previous-pos request)
609
+ (deactivate-mark )
610
+ (goto-char request))
577
611
((not previous-pos)
578
612
(deactivate-mark )
579
613
(goto-char (point-min ))
@@ -582,6 +616,9 @@ Useful if sending a request failed, perhaps from failed connectivity."
582
616
(deactivate-mark )
583
617
(goto-char previous-block)
584
618
(call-interactively #'chatgpt-shell-mark-block ))
619
+ ((eq previous-pos response)
620
+ (deactivate-mark )
621
+ (goto-char previous-pos))
585
622
((eq previous-pos previous-link)
586
623
(deactivate-mark )
587
624
(goto-char previous-link)))))
0 commit comments