Function: with-editor-locate-emacsclient-1

with-editor-locate-emacsclient-1 is a byte-compiled function defined in with-editor.el.

Signature

(with-editor-locate-emacsclient-1 PATH DEPTH)

Source Code

;; Defined in ~/.emacs.d/elpa/with-editor-20260301.1317/with-editor.el
(defun with-editor-locate-emacsclient-1 (path depth)
  (let* ((version-lst (cl-subseq (split-string emacs-version "\\.") 0 depth))
         (version-reg (concat "^" (string-join version-lst "\\."))))
    (or (locate-file
         (cond ((equal (downcase invocation-name) "remacs")
                "remacsclient")
               ((bound-and-true-p emacsclient-program-name))
               ("emacsclient"))
         path
         (mapcan (lambda (v) (cl-mapcar (lambda (e) (concat v e)) exec-suffixes))
                 (nconc (and (boundp 'debian-emacs-flavor)
                             (list (format ".%s" debian-emacs-flavor)))
                        (cl-mapcon (lambda (v)
                                     (setq v (string-join (reverse v) "."))
                                     (list v
                                           (concat "-" v)
                                           (concat ".emacs" v)))
                                   (reverse version-lst))
                        (cons "" with-editor-emacsclient-program-suffixes)))
         (lambda (exec)
           (ignore-errors
             (string-match-p version-reg
                             (with-editor-emacsclient-version exec)))))
        (and (> depth 1)
             (with-editor-locate-emacsclient-1 path (1- depth))))))