[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Function behaves differently when debugged
From: |
Matthias Pfeifer |
Subject: |
Function behaves differently when debugged |
Date: |
Tue, 15 May 2018 00:34:53 +0200 |
Hi everybody,
I have this function
(defun mp-ibuffer-show-file-path ()
(interactive)
(let ((buf (ibuffer-current-buffer))
(lsoutput nil))
(if (not (null buf))
(when (file-exists-p (buffer-file-name buf))
(with-temp-buffer
(let* ((filename (buffer-file-name buf))
(file-directory (file-name-directory filename))
(just-filename (file-name-nondirectory filename)))
(setq lsoutput file-directory))))
(setq lsoutput "Buffer is not backed by a file"))
(message lsoutput)))
I bind it to some key in ibuffer-mode. it should print the path to a
buffer's file. When point is on a line of a buffer that is not backed by a
file (eg *Messages*) then i get this output:
wrong type argument: strinp, nil
However when I instantiated my defun for debugging and do the same again I
get
"Buffer is not backed by a file"
The second behavior is actually what i had expected when i was writing the
function. The first behavior is a bit unexpected. Also I do not understand
why my function behaves differently when my defun is debugged and when it
run without debugging.
Thanks for your help.
Matthias
- Function behaves differently when debugged,
Matthias Pfeifer <=