summaryrefslogtreecommitdiff
path: root/lisp/mh-e/mh-compat.el
blob: 23dc48a574c704d3217ca8c3ad11d3886699c0dd (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
;;; mh-compat.el --- make MH-E compatible with various versions of Emacs  -*- lexical-binding: t; -*-

;; Copyright (C) 2006-2021 Free Software Foundation, Inc.

;; Author: Bill Wohler <wohler@newt.com>
;; Keywords: mail
;; See: mh-e.el

;; 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:

;;; Code:

;; This is a good place to gather code that is used for compatibility
;; between different versions of Emacs. Please document which versions
;; of Emacs that the defsubst, defalias, or defmacro applies. That
;; way, it's easy to occasionally go through this file and see which
;; macros we can retire.

;; Please use mh-gnus.el when providing compatibility with different
;; versions of Gnus.

;; Items are listed alphabetically.

(eval-when-compile (require 'mh-acros))

(define-obsolete-function-alias 'mh-require #'require "29.1")
(define-obsolete-function-alias 'mh-assoc-string #'assoc-string "29.1")
(define-obsolete-function-alias 'mh-cancel-timer #'cancel-timer "29.1")

;; Emacs 24 made flet obsolete and suggested either cl-flet or
;; cl-letf. This macro is based upon gmm-flet from Gnus.
(defmacro mh-flet (bindings &rest body)
  "Make temporary overriding function definitions.
That is, temporarily rebind the functions listed in BINDINGS and then
execute BODY.  BINDINGS is a list containing one or more lists of the
form (FUNCNAME ARGLIST BODY...), similar to defun."
  (declare (indent 1) (debug ((&rest (sexp sexp &rest form)) &rest form)))
  (if (fboundp 'cl-letf)
      `(cl-letf ,(mapcar (lambda (binding)
                           `((symbol-function ',(car binding))
                             (lambda ,@(cdr binding))))
                         bindings)
         ,@body)
    `(flet ,bindings ,@body)))

(define-obsolete-function-alias 'mh-display-color-cells
  #'display-color-cells "29.1")

(defmacro mh-display-completion-list (completions &optional common-substring)
  "Display the list of COMPLETIONS.
See documentation for `display-completion-list' for a description of the
arguments COMPLETIONS.
The optional argument COMMON-SUBSTRING, if non-nil, should be a string
specifying a common substring for adding the faces
`completions-first-difference' and `completions-common-part' to
the completions."
  `(display-completion-list
    (completion-hilit-commonality ,completions
                                  ,(length common-substring) nil)))

(define-obsolete-function-alias 'mh-face-foreground
  #'face-foreground "29.1")

(define-obsolete-function-alias 'mh-face-background
  #'face-background "29.1")

(define-obsolete-function-alias 'mh-font-lock-add-keywords
  #'font-lock-add-keywords "29.1")

;; Not preloaded in without-x builds.
(declare-function image-load-path-for-library "image")
(define-obsolete-function-alias 'mh-image-load-path-for-library
  #'image-load-path-for-library "29.1")

;; Not preloaded in without-x builds.
(declare-function image-search-load-path "image")
(define-obsolete-function-alias 'mh-image-search-load-path
  #'image-search-load-path "29.1")

(define-obsolete-function-alias 'mh-line-beginning-position
  #'line-beginning-position "29.1")

(define-obsolete-function-alias 'mh-line-end-position
  #'line-end-position "29.1")

(require 'mailabbrev nil t)
(define-obsolete-function-alias 'mh-mail-abbrev-make-syntax-table
  #'mail-abbrev-make-syntax-table "29.1")

(define-obsolete-function-alias 'mh-define-obsolete-variable-alias
  #'define-obsolete-variable-alias "29.1")

(define-obsolete-function-alias 'mh-make-obsolete-variable
  #'make-obsolete-variable "29.1")

(define-obsolete-function-alias 'mh-match-string-no-properties
  #'match-string-no-properties "29.1")

(define-obsolete-function-alias 'mh-replace-regexp-in-string
  #'replace-regexp-in-string "29.1")

(define-obsolete-function-alias 'mh-test-completion
  #'test-completion "29.1")

(defconst mh-url-unreserved-chars
  '(
    ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z
       ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z
       ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
       ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\))
  "A list of characters that are _NOT_ reserved in the URL spec.
This is taken from RFC 2396.")
(make-obsolete-variable 'mh-url-unreserved-chars 'url-unreserved-chars "29.1")

(define-obsolete-function-alias 'mh-url-hexify-string
  #'url-hexify-string "29.1")

(define-obsolete-function-alias 'mh-view-mode-enter
  #'view-mode-enter "29.1")

(define-obsolete-function-alias 'mh-window-full-height-p
  #'window-full-height-p "29.1")

(defmacro mh-write-file-functions ()
  "Return `write-file-functions'."
  (declare (obsolete nil "29.1"))
  ''write-file-functions)

(provide 'mh-compat)

;; Local Variables:
;; indent-tabs-mode: nil
;; sentence-end-double-space: nil
;; End:

;;; mh-compat.el ends here