[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>
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?, Richard Stallman, 2023/09/04
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?, Emanuel Berg, 2023/09/04
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?, tomas, 2023/09/05
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?,
Ihor Radchenko <=
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?, Adam Porter, 2023/09/05
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?, Lynn Winebarger, 2023/09/05
- Re: Why have a #if .... #else .... #endif construct in Emacs Lisp, when we could make the existing code DTRT unchanged?, Alan Mackenzie, 2023/09/05