all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: mah@everybody.org (Mark A. Hershberger)
Cc: rms@gnu.org, Emacs-devel@gnu.org
Subject: Re: xml-get-attribute returns "" if not found
Date: Thu, 13 Nov 2003 12:11:23 -0600	[thread overview]
Message-ID: <878ymk5eb8.fsf@weblog.localhost> (raw)
In-Reply-To: <E1AK8re-0002cu-Qj@fencepost.gnu.org> (Richard Stallman's message of "Wed, 12 Nov 2003 23:13:50 -0500")

Magnus Henoch <mange@freemail.hu> writes:

> In lisp/xml.el, the function xml-get-attribute returns "" if the requested
> attribute does not exist.  To me it seems that returning nil would make
> more sense in that case.

I totally agree.  I thought I had included this change before, but I
see now that it hasn't been applied.  I recommend that the patch be
applied.

Mark.

--- xml.el.old	Mon Nov  3 22:52:15 2003
+++ xml.el	Tue Nov  4 16:53:36 2003
@@ -104,15 +104,24 @@
 	      (push child match))))
     (nreverse match)))
 
-(defun xml-get-attribute (node attribute)
+(defun xml-get-attribute-or-nil (node attribute)
   "Get from NODE the value of ATTRIBUTE.
-An empty string is returned if the attribute was not found."
+nil is returned if the attribute was not found.
+
+See also `xml-get-attribute'."
   (if (xml-node-attributes node)
       (let ((value (assoc attribute (xml-node-attributes node))))
 	(if value
 	    (cdr value)
-	  ""))
-    ""))
+	  nil))
+    nil))
+
+(defsubst xml-get-attribute (node attribute)
+  "Get from NODE the value of ATTRIBUTE.
+An empty string is returned if the attribute was not found.
+
+See also `xml-get-attribute-or-nil'."
+  (or (xml-get-attribute-or-nil node attribute) ""))
 
 ;;*******************************************************************
 ;;**

       reply	other threads:[~2003-11-13 18:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1AK8re-0002cu-Qj@fencepost.gnu.org>
2003-11-13 18:11 ` Mark A. Hershberger [this message]
2003-11-14  9:32   ` xml-get-attribute returns "" if not found Andreas Schwab

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=878ymk5eb8.fsf@weblog.localhost \
    --to=mah@everybody.org \
    --cc=Emacs-devel@gnu.org \
    --cc=rms@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.