-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathtelega-obsolete.el
104 lines (84 loc) · 4.28 KB
/
telega-obsolete.el
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
;;; telega-obsolete.el --- Check the use of obsolete functionality -*- lexical-binding: t -*-
;; Copyright (C) 2020 by Zajcev Evgeny.
;; Author: Zajcev Evgeny <[email protected]>
;; Created: Fri Jan 17 14:55:16 2020
;; Keywords:
;; telega 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.
;; telega 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 telega. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Some telega functionality become obsolete sometimes.
;; telega warns user at load time in case he uses obsolete functionality.
;;; Code:
(require 'cl-lib)
(defvar telega-obsolete--variables nil
"List of obsolete variables to examine at load time.")
(defun telega-obsolete--variable (obsolete-name &rest args)
"Same as `make-obsolete-variable'."
(setq telega-obsolete--variables
(cl-pushnew obsolete-name telega-obsolete--variables))
(apply 'make-obsolete-variable obsolete-name args))
(defun telega-obsolete--warning (var obsolescence-data)
(let ((instead (car obsolescence-data))
(version (nth 2 obsolescence-data)))
(format-message
"`%S' is an obsolete in telega %s%s" var version
(cond ((stringp instead) (concat "; " (substitute-command-keys instead)))
(instead (format-message "; use `%s' instead." instead))
(t ".")))))
(telega-obsolete--variable 'telega-chat-use-markdown-formatting
'telega-chat-use-markdown-version "0.5.6")
(telega-obsolete--variable 'telega-use-tracking
'telega-use-tracking-for "0.5.7")
(telega-obsolete--variable 'telega-avatar-factors
'telega-avatar-factors-alist "0.5.8")
(telega-obsolete--variable 'telega-url-shorten-patterns
'telega-url-shorten-regexps "0.6.7")
(telega-obsolete--variable 'telega-chat-mark-observable-messages-as-read
nil "0.6.12")
(telega-obsolete--variable 'telega-root-compact-view
nil "0.6.21")
(telega-obsolete--variable 'telega-filter-custom-push-list
'telega-filter-custom-folders "0.6.24")
(telega-obsolete--variable 'telega-chat-label-format
'telega-chat-folder-format "0.6.30")
(telega-obsolete--variable 'telega-root-view-topics-custom-labels
'telega-root-view-topics-folders "0.6.30")
(telega-obsolete--variable 'telega-root-view-show-other-chats
'telega-root-view-topics-other-chats "0.6.30")
(telega-obsolete--variable 'telega-user-photo-maxsize
'telega-user-photo-size "0.6.30")
(telega-obsolete--variable 'telega-photo-maxsize
'telega-photo-size-limits "0.6.30")
(telega-obsolete--variable 'telega-thumbnail-height
'telega-thumbnail-size-limits "0.6.30")
(telega-obsolete--variable 'telega-webpage-photo-maxsize
'telega-webpage-photo-size-limits "0.6.30")
(telega-obsolete--variable 'telega-find-file-hook
'telega-open-file-hook "0.6.31")
(telega-obsolete--variable 'telega-chat-me-custom-title
'telega-chat-title-custom-for "0.6.31")
(telega-obsolete--variable 'telega-chat-reply-prompt
nil "0.7.0")
(telega-obsolete--variable 'telega-chat-edit-prompt
nil "0.7.0")
(telega-obsolete--variable 'telega-chat-messages-ring-size
'telega-chat-messages-pop-ring-size
nil "0.7.0")
;; Check some obsolete var/fun is used
(cl-eval-when (eval load)
(dolist (obsolete-var telega-obsolete--variables)
(when (boundp obsolete-var)
(display-warning
'telega (telega-obsolete--warning
obsolete-var (get obsolete-var 'byte-obsolete-variable)))))
)
(provide 'telega-obsolete)
;;; telega-obsolete.el ends here