Function: with-editor-sleeping-editor-filter

with-editor-sleeping-editor-filter is a byte-compiled function defined in with-editor.el.

Signature

(with-editor-sleeping-editor-filter PROCESS STRING)

Source Code

;; Defined in ~/.emacs.d/elpa/with-editor-20260301.1317/with-editor.el
(defun with-editor-sleeping-editor-filter (process string)
  (when-let ((incomplete (and process (process-get process 'incomplete))))
    (setq string (concat incomplete string)))
  (save-match-data
    (cond
      ((and process (not (string-suffix-p "\n" string)))
       (let ((length (length string)))
         (when (> length with-editor--max-incomplete-length)
           (setq string
                 (substring string
                            (- length with-editor--max-incomplete-length)))))
       (process-put process 'incomplete string)
       nil)
      ((string-match with-editor-sleeping-editor-regexp string)
       (when process
         (process-put process 'incomplete nil))
       (let ((pid  (match-string 1 string))
             (arg0 (match-string 2 string))
             (arg1 (match-string 3 string))
             (dir  (match-string 4 string))
             file line column)
         (cond ((string-match "\\`\\+\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?\\'" arg0)
                (setq file arg1)
                (setq line (string-to-number (match-string 1 arg0)))
                (setq column (match-string 2 arg0))
                (setq column (and column (string-to-number column))))
               ((setq file arg0)))
         (unless (file-name-absolute-p file)
           (setq file (expand-file-name file dir)))
         (when default-directory
           (setq file (concat (file-remote-p default-directory) file)))
         (with-current-buffer (find-file-noselect file)
           (with-editor-mode 1)
           (setq with-editor--pid pid)
           (setq with-editor-previous-winconf
                 (current-window-configuration))
           (when line
             (let ((pos (save-excursion
                          (save-restriction
                            (goto-char (point-min))
                            (forward-line (1- line))
                            (when column
                              (move-to-column column))
                            (point)))))
               (when (and (buffer-narrowed-p)
                          widen-automatically
                          (not (<= (point-min) pos (point-max))))
                 (widen))
               (goto-char pos)))
           (run-hooks 'with-editor-filter-visit-hook)
           (funcall (or (with-editor-server-window) #'switch-to-buffer)
                    (current-buffer))
           (kill-local-variable 'server-window)))
       nil)
      (t string))))