Skip to main content
Update to use string-trim
Source Link
Joe
  • 1k
  • 12
  • 18

I keep this one in my utils.lisp:

(defun empty-string-p (string)
  "Return true if the stringSTRING is empty or nil. Expects string type."
  (or (null string)
      (zerop (length (string-trim string)))))

then I do:

(not (empty-string-p some-string))

Emacs users: As of Emacs 26.3, trim throws Symbol's function definition is void. This page suggests functions starting in Emacs 24.4. The function is then:

(require 'subr-x)

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim-string string)))))

I keep this one in my utils.lisp:

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim string)))))

then I do:

(not (empty-string-p some-string))

Emacs users: As of Emacs 26.3, trim throws Symbol's function definition is void. This page suggests functions starting in Emacs 24.4. The function is then:

(require 'subr-x)

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim-string string)))))

I keep this one in my utils.lisp:

(defun empty-string-p (string)
  "Return true if the STRING is empty or nil. Expects string type."
  (or (null string)
      (zerop (length (string-trim string)))))

then I do:

(not (empty-string-p some-string))

I keep this one in my utils.lisputils.lisp:

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim string)))))
(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim string)))))

then I do:

(not (empty-string-p some-string))
(not (empty-string-p some-string))

Emacs users: As of Emacs 26.3, trim throws Symbol's function definition is void. This page suggests functions starting in Emacs 24.4. The function is then:

(require 'subr-x)

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim-string string)))))

I keep this one in my utils.lisp:

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim string)))))

then I do:

(not (empty-string-p some-string))

I keep this one in my utils.lisp:

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim string)))))

then I do:

(not (empty-string-p some-string))

Emacs users: As of Emacs 26.3, trim throws Symbol's function definition is void. This page suggests functions starting in Emacs 24.4. The function is then:

(require 'subr-x)

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim-string string)))))
Source Link
Joe
  • 1k
  • 12
  • 18

I keep this one in my utils.lisp:

(defun empty-string-p (string)
  "Return true if the string is empty or nil. Expects string."
  (or (null string)
      (zerop (length (trim string)))))

then I do:

(not (empty-string-p some-string))