emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when


From: Ihor Radchenko
Subject: Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?
Date: Tue, 05 Sep 2023 05:53:30 +0000

<tomas@tuxteam.de> writes:

> I did offer one: checking for a version number is actually a placeholder
> for the feature your code cares about. Better be up-front in the test
> and let the reader know what your code's needs are.

Not always. Sometimes, version check is necessary to work around bugs
that exist in older Emacs.

Example:

(defun org-string-width (string &optional pixels)
  "Return width of STRING when displayed in the current buffer.
Return width in pixels when PIXELS is non-nil."
  (if (and (version< emacs-version "28") (not pixels))
      ;; FIXME: Fallback to old limited version, because
      ;; `window-pixel-width' is buggy in older Emacs.
      (org--string-width-1 string)


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]