Function: range-normalize

range-normalize is a byte-compiled function defined in range.el.gz.

Signature

(range-normalize RANGE)

Documentation

Normalize RANGE.

If RANGE is a single range, return (RANGE). Otherwise, return RANGE.

Aliases

gnus-range-normalize (obsolete since 29.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/range.el.gz
;;; ranges.el --- range functions  -*- lexical-binding: t; -*-

;; Copyright (C) 1996-2026 Free Software Foundation, Inc.

;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; A "range" is a list that represents a list of integers.  A range is
;; a list containing cons cells of start/end pairs, as well as integers.
;;
;; ((2 . 5) 9 (11 . 13))
;;
;; represents the list (2 3 4 5 9 11 12 13).

;;; Code:

(defun range-normalize (range)
  "Normalize RANGE.
If RANGE is a single range, return (RANGE).  Otherwise, return RANGE."
  (if (listp (cdr-safe range))
      range
    (list range)))