all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matthias Pfeifer <pfemat@web.de>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Function behaves differently when debugged
Date: Tue, 15 May 2018 00:34:53 +0200	[thread overview]
Message-ID: <CAPzsW6iqppdn513JStGMftjp2=bokvOuSCyzhX=sq-0Ouppv3g@mail.gmail.com> (raw)

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


             reply	other threads:[~2018-05-14 22:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 22:34 Matthias Pfeifer [this message]
     [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.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPzsW6iqppdn513JStGMftjp2=bokvOuSCyzhX=sq-0Ouppv3g@mail.gmail.com' \
    --to=pfemat@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.