gptel: rear-nonsticky text-property by default
* gptel.el (gptel--insert-response, gptel--restore-state): Don't set the rear-nonsticky property on the gptel response text. Instead, the gptel text-property is globally declared to be nonsticky via `text-property-default-nonsticky`. This change is since markdown-mode makes rear-nonsticky a font-lock-managed property and we can't set it manually. Setting this property explicitly also makes all text properties in the range nonsticky, which can have unintended side effects. * gptel-curl.el (gptel-curl--stream-insert-response): Ditto.
This commit is contained in:
parent
b634f05fe5
commit
5e9e36d854
2 changed files with 9 additions and 9 deletions
|
@ -270,9 +270,8 @@ See `gptel--url-get-response' for details."
|
|||
(when transformer
|
||||
(setq response (funcall transformer response)))
|
||||
|
||||
(add-text-properties
|
||||
0 (length response) '(gptel response rear-nonsticky t)
|
||||
response)
|
||||
(put-text-property
|
||||
0 (length response) 'gptel 'response response)
|
||||
(goto-char tracking-marker)
|
||||
;; (run-hooks 'gptel-pre-stream-hook)
|
||||
(insert response)
|
||||
|
|
13
gptel.el
13
gptel.el
|
@ -656,8 +656,7 @@ for when gptel restores chat metadata."
|
|||
(progn
|
||||
(when-let ((bounds (org-entry-get (point-min) "GPTEL_BOUNDS")))
|
||||
(mapc (pcase-lambda (`(,beg . ,end))
|
||||
(add-text-properties
|
||||
beg end '(gptel response rear-nonsticky t)))
|
||||
(put-text-property beg end 'gptel 'response))
|
||||
(read bounds))
|
||||
(message "gptel chat restored."))
|
||||
(when-let ((model (org-entry-get (point-min) "GPTEL_MODEL")))
|
||||
|
@ -729,6 +728,9 @@ file."
|
|||
|
||||
;; Minor mode and UI
|
||||
|
||||
;; NOTE: It's not clear that this is the best strategy:
|
||||
(add-to-list 'text-property-default-nonsticky '(gptel . t))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode gptel-mode
|
||||
"Minor mode for interacting with LLMs."
|
||||
|
@ -984,9 +986,8 @@ See `gptel--url-get-response' for details."
|
|||
(setq response (gptel--transform-response
|
||||
response gptel-buffer))
|
||||
(save-excursion
|
||||
(add-text-properties
|
||||
0 (length response) '(gptel response rear-nonsticky t)
|
||||
response)
|
||||
(put-text-property
|
||||
0 (length response) 'gptel 'response response)
|
||||
(with-current-buffer (marker-buffer start-marker)
|
||||
(goto-char start-marker)
|
||||
(run-hooks 'gptel-pre-response-hook)
|
||||
|
@ -1486,7 +1487,7 @@ context for the ediff session."
|
|||
(nbutlast history))))
|
||||
(add-text-properties
|
||||
0 (length alt-response)
|
||||
`(gptel response rear-nonsticky t gptel-history ,history)
|
||||
`(gptel response gptel-history ,history)
|
||||
alt-response)
|
||||
(setq offset (min (- (point) beg) (1- (length alt-response))))
|
||||
(delete-region beg end)
|
||||
|
|
Loading…
Add table
Reference in a new issue