aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBasil L. Contovounesios2019-04-17 17:35:12 +0100
committerBasil L. Contovounesios2019-04-21 19:04:13 +0100
commit3a618e5f89c86bc96925b06647fb33568c8fa2c9 (patch)
tree77487517357855b75b3551f3dddcb929ce3d0195
parent2ea55c2774e726c7e393ee81b152aa9734c410cb (diff)
downloademacs-3a618e5f89c86bc96925b06647fb33568c8fa2c9.tar.gz
emacs-3a618e5f89c86bc96925b06647fb33568c8fa2c9.zip
Move side-effect-free from unsafep.el to subr.el
* lisp/emacs-lisp/unsafep.el: Move side-effect-free property setting from here... * lisp/subr.el: ...to here, as function declarations for modularity.
-rw-r--r--lisp/emacs-lisp/unsafep.el5
-rw-r--r--lisp/subr.el8
2 files changed, 8 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/unsafep.el b/lisp/emacs-lisp/unsafep.el
index d20b751d88a..1a2f1f31b10 100644
--- a/lisp/emacs-lisp/unsafep.el
+++ b/lisp/emacs-lisp/unsafep.el
@@ -92,11 +92,6 @@
92in the parse.") 92in the parse.")
93(put 'unsafep-vars 'risky-local-variable t) 93(put 'unsafep-vars 'risky-local-variable t)
94 94
95;;Side-effect-free functions from subr.el
96(dolist (x '(assoc-default butlast last match-string
97 match-string-no-properties member-ignore-case remove remq))
98 (put x 'side-effect-free t))
99
100;;Other safe functions 95;;Other safe functions
101(dolist (x '(;;Special forms 96(dolist (x '(;;Special forms
102 and catch if or prog1 prog2 progn while unwind-protect 97 and catch if or prog1 prog2 progn while unwind-protect
diff --git a/lisp/subr.el b/lisp/subr.el
index bf3716bbd37..f68f9dd4191 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -580,6 +580,7 @@ i.e., subtract 2 * most-negative-fixnum from VALUE before shifting it."
580If LIST is nil, return nil. 580If LIST is nil, return nil.
581If N is non-nil, return the Nth-to-last link of LIST. 581If N is non-nil, return the Nth-to-last link of LIST.
582If N is bigger than the length of LIST, return LIST." 582If N is bigger than the length of LIST, return LIST."
583 (declare (side-effect-free t))
583 (if n 584 (if n
584 (and (>= n 0) 585 (and (>= n 0)
585 (let ((m (safe-length list))) 586 (let ((m (safe-length list)))
@@ -591,6 +592,7 @@ If N is bigger than the length of LIST, return LIST."
591 "Return a copy of LIST with the last N elements removed. 592 "Return a copy of LIST with the last N elements removed.
592If N is omitted or nil, the last element is removed from the 593If N is omitted or nil, the last element is removed from the
593copy." 594copy."
595 (declare (side-effect-free t))
594 (if (and n (<= n 0)) list 596 (if (and n (<= n 0)) list
595 (nbutlast (copy-sequence list) n))) 597 (nbutlast (copy-sequence list) n)))
596 598
@@ -726,6 +728,7 @@ If that is non-nil, the element matches; then `assoc-default'
726 728
727If no element matches, the value is nil. 729If no element matches, the value is nil.
728If TEST is omitted or nil, `equal' is used." 730If TEST is omitted or nil, `equal' is used."
731 (declare (side-effect-free t))
729 (let (found (tail alist) value) 732 (let (found (tail alist) value)
730 (while (and tail (not found)) 733 (while (and tail (not found))
731 (let ((elt (car tail))) 734 (let ((elt (car tail)))
@@ -739,6 +742,7 @@ If TEST is omitted or nil, `equal' is used."
739ELT must be a string. Upper-case and lower-case letters are treated as equal. 742ELT must be a string. Upper-case and lower-case letters are treated as equal.
740Unibyte strings are converted to multibyte for comparison. 743Unibyte strings are converted to multibyte for comparison.
741Non-strings in LIST are ignored." 744Non-strings in LIST are ignored."
745 (declare (side-effect-free t))
742 (while (and list 746 (while (and list
743 (not (and (stringp (car list)) 747 (not (and (stringp (car list))
744 (eq t (compare-strings elt 0 nil (car list) 0 nil t))))) 748 (eq t (compare-strings elt 0 nil (car list) 0 nil t)))))
@@ -822,6 +826,7 @@ Example:
822(defun remove (elt seq) 826(defun remove (elt seq)
823 "Return a copy of SEQ with all occurrences of ELT removed. 827 "Return a copy of SEQ with all occurrences of ELT removed.
824SEQ must be a list, vector, or string. The comparison is done with `equal'." 828SEQ must be a list, vector, or string. The comparison is done with `equal'."
829 (declare (side-effect-free t))
825 (if (nlistp seq) 830 (if (nlistp seq)
826 ;; If SEQ isn't a list, there's no need to copy SEQ because 831 ;; If SEQ isn't a list, there's no need to copy SEQ because
827 ;; `delete' will return a new object. 832 ;; `delete' will return a new object.
@@ -832,6 +837,7 @@ SEQ must be a list, vector, or string. The comparison is done with `equal'."
832 "Return LIST with all occurrences of ELT removed. 837 "Return LIST with all occurrences of ELT removed.
833The comparison is done with `eq'. Contrary to `delq', this does not use 838The comparison is done with `eq'. Contrary to `delq', this does not use
834side-effects, and the argument LIST is not modified." 839side-effects, and the argument LIST is not modified."
840 (declare (side-effect-free t))
835 (while (and (eq elt (car list)) (setq list (cdr list)))) 841 (while (and (eq elt (car list)) (setq list (cdr list))))
836 (if (memq elt list) 842 (if (memq elt list)
837 (delq elt (copy-sequence list)) 843 (delq elt (copy-sequence list))
@@ -3898,6 +3904,7 @@ Zero means the entire text matched by the whole regexp or whole string.
3898STRING should be given if the last search was by `string-match' on STRING. 3904STRING should be given if the last search was by `string-match' on STRING.
3899If STRING is nil, the current buffer should be the same buffer 3905If STRING is nil, the current buffer should be the same buffer
3900the search/match was performed in." 3906the search/match was performed in."
3907 (declare (side-effect-free t))
3901 (if (match-beginning num) 3908 (if (match-beginning num)
3902 (if string 3909 (if string
3903 (substring string (match-beginning num) (match-end num)) 3910 (substring string (match-beginning num) (match-end num))
@@ -3911,6 +3918,7 @@ Zero means the entire text matched by the whole regexp or whole string.
3911STRING should be given if the last search was by `string-match' on STRING. 3918STRING should be given if the last search was by `string-match' on STRING.
3912If STRING is nil, the current buffer should be the same buffer 3919If STRING is nil, the current buffer should be the same buffer
3913the search/match was performed in." 3920the search/match was performed in."
3921 (declare (side-effect-free t))
3914 (if (match-beginning num) 3922 (if (match-beginning num)
3915 (if string 3923 (if string
3916 (substring-no-properties string (match-beginning num) 3924 (substring-no-properties string (match-beginning num)