about summary refs log tree commit diff
path: root/configs/shared/emacs/.emacs.d/elpa/circe-20180525.1231/circe-compat.el
blob: f509c66d5b149678ba66de38a32b26338977b0ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;;; circe-compat.el --- Compatibility definitions

;; Copyright (C) 2015  Jorgen Schaefer <contact@jorgenschaefer.de>

;; Author: Jorgen Schaefer <contact@jorgenschaefer.de>

;; This program 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.

;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Define functions and variables as needed by Circe to remain
;; compatible with older Emacsen.

;;; Code:

(when (not (fboundp 'string-trim))
  (defun string-trim (string)
    "Remove leading and trailing whitespace from STRING."
    (if (string-match "\\` *\\(.*[^[:space:]]\\) *\\'" string)
        (match-string 1 string)
      string)))

(when (not (fboundp 'add-face-text-property))
  (defun add-face-text-property (start end face &optional append object)
    (while (/= start end)
      (let* ((next (next-single-property-change start 'face object end))
             (prev (get-text-property start 'face object))
             (value (if (listp prev) prev (list prev))))
        (put-text-property start next 'face
                           (if append
                               (append value (list face))
                             (append (list face) value))
                           object)
        (setq start next)))))

(when (not (boundp 'mode-line-misc-info))
  (defvar mode-line-misc-info nil
    "Misc info in the mode line.")
  (add-to-list 'mode-line-format 'mode-line-misc-info t))

(provide 'circe-compat)
;;; circe-compat.el ends here