forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-compat.el
42 lines (35 loc) · 2.03 KB
/
init-compat.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
;;----------------------------------------------------------------------------
;; Provide a version of Emacs 24's 'string-prefix-p in older emacsen
;;----------------------------------------------------------------------------
(unless (fboundp 'string-prefix-p)
(defun string-prefix-p (str1 str2 &optional ignore-case)
"Return non-nil if STR1 is a prefix of STR2.
If IGNORE-CASE is non-nil, the comparison is done without paying attention
to case differences."
(eq t (compare-strings str1 nil nil
str2 0 (length str1) ignore-case))))
;;----------------------------------------------------------------------------
;; Allow recent packages to safely pass an arg to 'called-interactively-p
;; in older Emacsen, including 23.1.
;;----------------------------------------------------------------------------
(let ((fn (symbol-function 'called-interactively-p)))
(when (zerop (cdr-safe (subr-arity fn)))
(message "Warning: overriding called-interactively-p to support an argument.")
(fset 'sanityinc/called-interactively-p fn)
(defun called-interactively-p (&optional kind)
"Overridden; see `sanityinc/called-interactively-p' for the wrapped function."
(sanityinc/called-interactively-p))))
(when (< emacs-major-version 24)
;; Help package.el work in older Emacsen, where there's no TRASH arg
;; for 'delete-directory
(message "Warning: overriding delete-directory to support TRASH argument.")
(fset 'sanityinc/delete-directory (symbol-function 'delete-directory))
(defun delete-directory (directory &optional recursive trash)
"Overridden: see `sanityinc/delete-directory' for the wrapped function"
(sanityinc/delete-directory directory recursive)))
;;----------------------------------------------------------------------------
;; Restore removed var alias, used by ruby-electric-brace and others
;;----------------------------------------------------------------------------
(unless (boundp 'last-command-char)
(defvaralias 'last-command-char 'last-command-event))
(provide 'init-compat)