Suppose I call a function which is named as
Sometimes that function
foo will give a message such as
"Example of error message". If that is the case, then something else should be executed.
This means that I need a way that to read the output of the messages buffer.
In particular, I want to define a function
bar that calls
foo and executes something when
foo gives a error:
(defun bar () (foo) (if (string-match `"Example of error message"` (minibuffer-output after calling foo)) then do this) else do this thingy).
When I read the Emacs Documentation, I couldn't find anything that gives the functionality of reading the latest message from the minibuffer.
Any suggestion would be appreciated.
SITUATION FROM THE REAL WORLD:
It seems my post is not clear enough. I will detail it further from the actual situation here. I have the following:
(defun foo () (interactive) (evil-goto-mark ?8) )
Calling the function
foo produces the error
Marker 8' is not set in this buffer.
If I get that message after calling
(evil-goto-mark ?8), I want to call
(evil-set-marker ?8) instead. The answer below didn't work in my case, unfortunately.