all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function behaves differently when debugged
@ 2018-05-14 22:34 Matthias Pfeifer
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Pfeifer @ 2018-05-14 22:34 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-21 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.3.1526337298.20804.help-gnu-emacs@gnu.org>
2018-05-15 14:48 ` Function behaves differently when debugged Ralf Fassel
2018-05-21 21:34 ` Robert L.
2018-05-14 22:34 Matthias Pfeifer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.