I am trying to play with the make-process
function and get information from it. I am getting some errors in my process filter that I am having trouble understanding. When I run my ceedling-version
function, which makes the process and associates the filter and command to the process, I get:
error in process filter: string-match: No match data, because no search succeeded
error in process filter: No match data, because no search succeeded
Version a-list: ((ceedling . 0.28.2) (cmock . 2.4.5) (unity . 2.4.2) (cexception . 1.3.1))
So it does seem to perform properly but it is still showing these errors in the process filter. I am testing with the same string that gets passed to my filter function.
I have tests that test the functions that my filter calls:
;;; Code:
(require 'ert)
(require 'ceedmacs)
(defvar test-directory "../test-data/temp_sensor")
(defvar ceedling-version-output "Welcome to Ceedling!\n Ceedling:: 0.28.2\n CMock:: 2.4.5\n Unity:: 2.4.2\n CException:: 1.3.1\n\nProcess ceedling finished\n")
(ert-deftest version-regex-test ()
(should (equal (regex-version "Ceedling::[[:space:]]*" ceedling-version-output) "0.28.2"))
(should (equal (regex-version "CMock::[[:space:]]*" ceedling-version-output) "2.4.5"))
(should (equal (regex-version "Unity::[[:space:]]*" ceedling-version-output) "2.4.2"))
(should (equal (regex-version "CException::[[:space:]]*" ceedling-version-output) "1.3.1"))
)
(ert-deftest version-alist-test ()
(let (version-alist)
(setq version-alist `((ceedling . ,(regex-version "Ceedling::[[:space:]]*" ceedling-version-output))
(cmock . ,(regex-version "CMock::[[:space:]]*" ceedling-version-output))
(unity . ,(regex-version "Unity::[[:space:]]*" ceedling-version-output))
(cexception . ,(regex-version "CException::[[:space:]]*" ceedling-version-output))))
(should (equal (alist-get 'ceedling version-alist) "0.28.2"))
(should (equal (alist-get 'cmock version-alist) "2.4.5"))
(should (equal (alist-get 'unity version-alist) "2.4.2"))
(should (equal (alist-get 'cexception version-alist) "1.3.1"))
)
)
;;; ceedmacs-test.el ends here
These tests pass just fine so I'm trying to figure out where these error in process filter messages are coming from because my process filter really doesn't do anything else besides make an alist
My code:
;;; Code:
(defvar ceedling-version-alist)
(defun regex-version (regex string)
"Use REGEX to find version in STRING."
(progn
(string-match regex string)
(string-match "[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*" string (match-end 0))
(match-string 0 string)
)
)
(defun ceedmacs--version-filter (process string)
"Filter function for PROCESS, which processes STRING to find the version.
Typical output:
Welcome to Ceedling!
Ceedling:: 0.28.2
CMock:: 2.4.5
Unity:: 2.4.2
CException:: 1.3.1"
(setq ceedling-version-alist `(
(ceedling . ,(regex-version "Ceedling::[[:space:]]*" string))
(cmock . ,(regex-version "CMock::[[:space:]]*" string))
(unity . ,(regex-version "Unity::[[:space:]]*" string))
(cexception . ,(regex-version "CException::[[:space:]]*" string))
))
)
(defun ceedling-version ()
"Return association list represting ceedling version."
(interactive)
(let (
(proc-name "Ceedling Process")
version-proc
)
(accept-process-output
(make-process
:name proc-name
:command '("ceedling" "version")
:filter 'ceedmacs--version-filter
))
(message (format "Version a-list: %s" ceedling-version-alist))
))
(provide 'ceedmacs)
;;; ceedmacs.el ends here
```
On another note, I am trying to get my alist that I create in the filter process out so I am setting a global variable equal to it. Is there a better way to get information out? It seems like I could write something to a buffer and then evaluate it or do the global variable method.
Thanks for any tips, tricks, or input