diff options
| author | Harald Jörg | 2020-09-26 15:51:15 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-09-26 15:51:15 +0200 |
| commit | 2de618ed5d3a160d54c7b5bb69f961e4ff6cc2f7 (patch) | |
| tree | f05254bc7b94476b735c982e7ad47ad353946b0c | |
| parent | e00936bf9f10cf44e1df71a7a11afd770e8a122a (diff) | |
| download | emacs-2de618ed5d3a160d54c7b5bb69f961e4ff6cc2f7.tar.gz emacs-2de618ed5d3a160d54c7b5bb69f961e4ff6cc2f7.zip | |
cperl-mode: Delete conditional code where conditions evaluate to nil
* lisp/progmodes/cperl-mode.el (cperl-force-face): This
macro's single effect is now inlined, and the macro is gone.
(cperl-problems): The reference to choose-color.el, which
is no longer available for download, is deleted.
(no function): A list of unnecessary empty variable
definitions is gone. They were needed for Emacs v19 and
below.
(cperl-init-faces-weak): This function does no longer do
anything and is therefore deleted.
(cperl-init-faces): Some bodies of conditional code is deleted
because as of today the conditions evaluate to constants. The
face cperl-nonoverridable-face is no longer available as
variable and needs to be doubly-quoted in one place (bug#43622).
| -rw-r--r-- | lisp/progmodes/cperl-mode.el | 218 |
1 files changed, 6 insertions, 212 deletions
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 468ffc949a6..6313d015e9f 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el | |||
| @@ -82,13 +82,6 @@ | |||
| 82 | (defvar vc-rcs-header) | 82 | (defvar vc-rcs-header) |
| 83 | (defvar vc-sccs-header) | 83 | (defvar vc-sccs-header) |
| 84 | 84 | ||
| 85 | (defmacro cperl-force-face (arg descr) ; Takes unquoted arg | ||
| 86 | `(progn | ||
| 87 | (or (facep (quote ,arg)) | ||
| 88 | (make-face ,arg)) | ||
| 89 | (or (boundp (quote ,arg)) ; We use unquoted variants too | ||
| 90 | (defvar ,arg (quote ,arg) ,descr)))) | ||
| 91 | |||
| 92 | (defun cperl-choose-color (&rest list) | 85 | (defun cperl-choose-color (&rest list) |
| 93 | (let (answer) | 86 | (let (answer) |
| 94 | (while list | 87 | (while list |
| @@ -663,10 +656,6 @@ micro-docs on what I know about CPerl problems.") | |||
| 663 | 656 | ||
| 664 | (defvar cperl-problems 'please-ignore-this-line | 657 | (defvar cperl-problems 'please-ignore-this-line |
| 665 | "Description of problems in CPerl mode. | 658 | "Description of problems in CPerl mode. |
| 666 | Some faces will not be shown on some versions of Emacs unless you | ||
| 667 | install choose-color.el, available from | ||
| 668 | http://ilyaz.org/software/emacs | ||
| 669 | |||
| 670 | `fill-paragraph' on a comment may leave the point behind the | 659 | `fill-paragraph' on a comment may leave the point behind the |
| 671 | paragraph. It also triggers a bug in some versions of Emacs (CPerl tries | 660 | paragraph. It also triggers a bug in some versions of Emacs (CPerl tries |
| 672 | to detect it and bulk out). | 661 | to detect it and bulk out). |
| @@ -1715,10 +1704,9 @@ or as help on variables `cperl-tips', `cperl-problems', | |||
| 1715 | (if cperl-hook-after-change | 1704 | (if cperl-hook-after-change |
| 1716 | (add-hook 'after-change-functions #'cperl-after-change-function nil t)) | 1705 | (add-hook 'after-change-functions #'cperl-after-change-function nil t)) |
| 1717 | ;; After hooks since fontification will break this | 1706 | ;; After hooks since fontification will break this |
| 1718 | (if cperl-pod-here-scan | 1707 | (when (and cperl-pod-here-scan |
| 1719 | (or cperl-syntaxify-by-font-lock | 1708 | (not cperl-syntaxify-by-font-lock)) |
| 1720 | (progn (or cperl-faces-init (cperl-init-faces-weak)) | 1709 | (cperl-find-pods-heres)) |
| 1721 | (cperl-find-pods-heres)))) | ||
| 1722 | ;; Setup Flymake | 1710 | ;; Setup Flymake |
| 1723 | (add-hook 'flymake-diagnostic-functions #'perl-flymake nil t)) | 1711 | (add-hook 'flymake-diagnostic-functions #'perl-flymake nil t)) |
| 1724 | 1712 | ||
| @@ -3262,9 +3250,6 @@ Works before syntax recognition is done." | |||
| 3262 | result)) | 3250 | result)) |
| 3263 | 3251 | ||
| 3264 | 3252 | ||
| 3265 | (defvar font-lock-string-face) | ||
| 3266 | ;;(defvar font-lock-reference-face) | ||
| 3267 | (defvar font-lock-constant-face) | ||
| 3268 | (defsubst cperl-postpone-fontification (b e type val &optional now) | 3253 | (defsubst cperl-postpone-fontification (b e type val &optional now) |
| 3269 | ;; Do after syntactic fontification? | 3254 | ;; Do after syntactic fontification? |
| 3270 | (if cperl-syntaxify-by-font-lock | 3255 | (if cperl-syntaxify-by-font-lock |
| @@ -3330,16 +3315,6 @@ Works before syntax recognition is done." | |||
| 3330 | (setq end (point))))) | 3315 | (setq end (point))))) |
| 3331 | (or end pos))))) | 3316 | (or end pos))))) |
| 3332 | 3317 | ||
| 3333 | ;; These are needed for byte-compile (at least with v19) | ||
| 3334 | (defvar cperl-nonoverridable-face) | ||
| 3335 | (defvar font-lock-variable-name-face) | ||
| 3336 | (defvar font-lock-function-name-face) | ||
| 3337 | (defvar font-lock-keyword-face) | ||
| 3338 | (defvar font-lock-builtin-face) | ||
| 3339 | (defvar font-lock-type-face) | ||
| 3340 | (defvar font-lock-comment-face) | ||
| 3341 | (defvar font-lock-warning-face) | ||
| 3342 | |||
| 3343 | (defun cperl-find-sub-attrs (&optional st-l b-fname e-fname pos) | 3318 | (defun cperl-find-sub-attrs (&optional st-l b-fname e-fname pos) |
| 3344 | "Syntactically mark (and fontify) attributes of a subroutine. | 3319 | "Syntactically mark (and fontify) attributes of a subroutine. |
| 3345 | Should be called with the point before leading colon of an attribute." | 3320 | Should be called with the point before leading colon of an attribute." |
| @@ -5474,17 +5449,6 @@ indentation and initial hashes. Behaves usually outside of comment." | |||
| 5474 | (or cperl-faces-init (cperl-init-faces)) | 5449 | (or cperl-faces-init (cperl-init-faces)) |
| 5475 | cperl-font-lock-keywords-2) | 5450 | cperl-font-lock-keywords-2) |
| 5476 | 5451 | ||
| 5477 | (defun cperl-init-faces-weak () | ||
| 5478 | ;; Allow `cperl-find-pods-heres' to run. | ||
| 5479 | (or (boundp 'font-lock-constant-face) | ||
| 5480 | (cperl-force-face font-lock-constant-face | ||
| 5481 | "Face for constant and label names")) | ||
| 5482 | (or (boundp 'font-lock-warning-face) | ||
| 5483 | (cperl-force-face font-lock-warning-face | ||
| 5484 | "Face for things which should stand out")) | ||
| 5485 | ;;(setq font-lock-constant-face 'font-lock-constant-face) | ||
| 5486 | ) | ||
| 5487 | |||
| 5488 | (defun cperl-init-faces () | 5452 | (defun cperl-init-faces () |
| 5489 | (condition-case errs | 5453 | (condition-case errs |
| 5490 | (progn | 5454 | (progn |
| @@ -5612,7 +5576,7 @@ indentation and initial hashes. Behaves usually outside of comment." | |||
| 5612 | "wh\\(en\\|ile\\)\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually | 5576 | "wh\\(en\\|ile\\)\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually |
| 5613 | "\\|[sm]" ; Added manually | 5577 | "\\|[sm]" ; Added manually |
| 5614 | "\\)\\>") | 5578 | "\\)\\>") |
| 5615 | 2 'cperl-nonoverridable-face) | 5579 | 2 ''cperl-nonoverridable-face) ; unbound as var, so: doubly quoted |
| 5616 | ;; (mapconcat #'identity | 5580 | ;; (mapconcat #'identity |
| 5617 | ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if" | 5581 | ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if" |
| 5618 | ;; "#include" "#define" "#undef") | 5582 | ;; "#include" "#define" "#undef") |
| @@ -5648,11 +5612,7 @@ indentation and initial hashes. Behaves usually outside of comment." | |||
| 5648 | 2 font-lock-function-name-face) | 5612 | 2 font-lock-function-name-face) |
| 5649 | '("^[ \t]*format[ \t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t]*=[ \t]*$" | 5613 | '("^[ \t]*format[ \t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t]*=[ \t]*$" |
| 5650 | 1 font-lock-function-name-face) | 5614 | 1 font-lock-function-name-face) |
| 5651 | (cond ((featurep 'font-lock-extra) | 5615 | (cond (font-lock-anchored |
| 5652 | '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" | ||
| 5653 | (2 font-lock-string-face t) | ||
| 5654 | (0 '(restart 2 t)))) ; To highlight $a{bc}{ef} | ||
| 5655 | (font-lock-anchored | ||
| 5656 | '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" | 5616 | '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" |
| 5657 | (2 font-lock-string-face t) | 5617 | (2 font-lock-string-face t) |
| 5658 | ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" | 5618 | ("\\=[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" |
| @@ -5670,15 +5630,7 @@ indentation and initial hashes. Behaves usually outside of comment." | |||
| 5670 | ;;; '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face) | 5630 | ;;; '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face) |
| 5671 | ;;; '("\\([@%]\\|\\$#\\)\\(\\sw+\\)" | 5631 | ;;; '("\\([@%]\\|\\$#\\)\\(\\sw+\\)" |
| 5672 | ;;; (2 (cons font-lock-variable-name-face '(underline)))) | 5632 | ;;; (2 (cons font-lock-variable-name-face '(underline)))) |
| 5673 | (cond ((featurep 'font-lock-extra) | 5633 | (cond (font-lock-anchored |
| 5674 | '("^[ \t]*\\(state\\|my\\|local\\|our\\)[ \t]*\\(([ \t]*\\)?\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?" | ||
| 5675 | (3 font-lock-variable-name-face) | ||
| 5676 | (4 '(another 4 nil | ||
| 5677 | ("\\=[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?" | ||
| 5678 | (1 font-lock-variable-name-face) | ||
| 5679 | (2 '(restart 2 nil) nil t))) | ||
| 5680 | nil t))) ; local variables, multiple | ||
| 5681 | (font-lock-anchored | ||
| 5682 | ;; 1=my_etc, 2=white? 3=(+white? 4=white? 5=var | 5634 | ;; 1=my_etc, 2=white? 3=(+white? 4=white? 5=var |
| 5683 | `(,(concat "\\<\\(state\\|my\\|local\\|our\\)" | 5635 | `(,(concat "\\<\\(state\\|my\\|local\\|our\\)" |
| 5684 | cperl-maybe-white-and-comment-rex | 5636 | cperl-maybe-white-and-comment-rex |
| @@ -5780,164 +5732,6 @@ indentation and initial hashes. Behaves usually outside of comment." | |||
| 5780 | t-font-lock-keywords-1 | 5732 | t-font-lock-keywords-1 |
| 5781 | cperl-font-lock-keywords-1))) | 5733 | cperl-font-lock-keywords-1))) |
| 5782 | (if (fboundp 'ps-print-buffer) (cperl-ps-print-init)) | 5734 | (if (fboundp 'ps-print-buffer) (cperl-ps-print-init)) |
| 5783 | (if (or (featurep 'choose-color) (featurep 'font-lock-extra)) | ||
| 5784 | (eval ; Avoid a warning | ||
| 5785 | '(font-lock-require-faces | ||
| 5786 | (list | ||
| 5787 | ;; Color-light Color-dark Gray-light Gray-dark Mono | ||
| 5788 | (list 'font-lock-comment-face | ||
| 5789 | ["Firebrick" "OrangeRed" "DimGray" "Gray80"] | ||
| 5790 | nil | ||
| 5791 | [nil nil t t t] | ||
| 5792 | [nil nil t t t] | ||
| 5793 | nil) | ||
| 5794 | (list 'font-lock-string-face | ||
| 5795 | ["RosyBrown" "LightSalmon" "Gray50" "LightGray"] | ||
| 5796 | nil | ||
| 5797 | nil | ||
| 5798 | [nil nil t t t] | ||
| 5799 | nil) | ||
| 5800 | (list 'font-lock-function-name-face | ||
| 5801 | (vector | ||
| 5802 | "Blue" "LightSkyBlue" "Gray50" "LightGray" | ||
| 5803 | (cdr (assq 'background-color ; if mono | ||
| 5804 | (frame-parameters)))) | ||
| 5805 | (vector | ||
| 5806 | nil nil nil nil | ||
| 5807 | (cdr (assq 'foreground-color ; if mono | ||
| 5808 | (frame-parameters)))) | ||
| 5809 | [nil nil t t t] | ||
| 5810 | nil | ||
| 5811 | nil) | ||
| 5812 | (list 'font-lock-variable-name-face | ||
| 5813 | ["DarkGoldenrod" "LightGoldenrod" "DimGray" "Gray90"] | ||
| 5814 | nil | ||
| 5815 | [nil nil t t t] | ||
| 5816 | [nil nil t t t] | ||
| 5817 | nil) | ||
| 5818 | (list 'font-lock-type-face | ||
| 5819 | ["DarkOliveGreen" "PaleGreen" "DimGray" "Gray80"] | ||
| 5820 | nil | ||
| 5821 | [nil nil t t t] | ||
| 5822 | nil | ||
| 5823 | [nil nil t t t]) | ||
| 5824 | (list 'font-lock-warning-face | ||
| 5825 | ["Pink" "Red" "Gray50" "LightGray"] | ||
| 5826 | ["gray20" "gray90" | ||
| 5827 | "gray80" "gray20"] | ||
| 5828 | [nil nil t t t] | ||
| 5829 | nil | ||
| 5830 | [nil nil t t t] | ||
| 5831 | ) | ||
| 5832 | (list 'font-lock-constant-face | ||
| 5833 | ["CadetBlue" "Aquamarine" "Gray50" "LightGray"] | ||
| 5834 | nil | ||
| 5835 | [nil nil t t t] | ||
| 5836 | nil | ||
| 5837 | [nil nil t t t]) | ||
| 5838 | (list 'cperl-nonoverridable-face | ||
| 5839 | ["chartreuse3" ("orchid1" "orange") | ||
| 5840 | nil "Gray80"] | ||
| 5841 | [nil nil "gray90"] | ||
| 5842 | [nil nil nil t t] | ||
| 5843 | [nil nil t t] | ||
| 5844 | [nil nil t t t]) | ||
| 5845 | (list 'cperl-array-face | ||
| 5846 | ["blue" "yellow" nil "Gray80"] | ||
| 5847 | ["lightyellow2" ("navy" "os2blue" "darkgreen") | ||
| 5848 | "gray90"] | ||
| 5849 | t | ||
| 5850 | nil | ||
| 5851 | nil) | ||
| 5852 | (list 'cperl-hash-face | ||
| 5853 | ["red" "red" nil "Gray80"] | ||
| 5854 | ["lightyellow2" ("navy" "os2blue" "darkgreen") | ||
| 5855 | "gray90"] | ||
| 5856 | t | ||
| 5857 | t | ||
| 5858 | nil)))) | ||
| 5859 | ;; Do it the dull way, without choose-color | ||
| 5860 | (cperl-force-face font-lock-constant-face | ||
| 5861 | "Face for constant and label names") | ||
| 5862 | (cperl-force-face font-lock-variable-name-face | ||
| 5863 | "Face for variable names") | ||
| 5864 | (cperl-force-face font-lock-type-face | ||
| 5865 | "Face for data types") | ||
| 5866 | (cperl-force-face cperl-nonoverridable-face | ||
| 5867 | "Face for data types from another group") | ||
| 5868 | (cperl-force-face font-lock-warning-face | ||
| 5869 | "Face for things which should stand out") | ||
| 5870 | (cperl-force-face font-lock-comment-face | ||
| 5871 | "Face for comments") | ||
| 5872 | (cperl-force-face font-lock-function-name-face | ||
| 5873 | "Face for function names") | ||
| 5874 | ;;(defvar font-lock-constant-face 'font-lock-constant-face) | ||
| 5875 | ;;(defvar font-lock-variable-name-face 'font-lock-variable-name-face) | ||
| 5876 | ;;(or (boundp 'font-lock-type-face) | ||
| 5877 | ;; (defconst font-lock-type-face | ||
| 5878 | ;; 'font-lock-type-face | ||
| 5879 | ;; "Face to use for data types.")) | ||
| 5880 | ;;(or (boundp 'cperl-nonoverridable-face) | ||
| 5881 | ;; (defconst cperl-nonoverridable-face | ||
| 5882 | ;; 'cperl-nonoverridable-face | ||
| 5883 | ;; "Face to use for data types from another group.")) | ||
| 5884 | (if (and | ||
| 5885 | (not (facep 'cperl-array-face)) | ||
| 5886 | (facep 'font-lock-emphasized-face)) | ||
| 5887 | (copy-face 'font-lock-emphasized-face 'cperl-array-face)) | ||
| 5888 | (if (and | ||
| 5889 | (not (facep 'cperl-hash-face)) | ||
| 5890 | (facep 'font-lock-other-emphasized-face)) | ||
| 5891 | (copy-face 'font-lock-other-emphasized-face 'cperl-hash-face)) | ||
| 5892 | (if (and | ||
| 5893 | (not (facep 'cperl-nonoverridable-face)) | ||
| 5894 | (facep 'font-lock-other-type-face)) | ||
| 5895 | (copy-face 'font-lock-other-type-face 'cperl-nonoverridable-face)) | ||
| 5896 | ;;(or (boundp 'cperl-hash-face) | ||
| 5897 | ;; (defconst cperl-hash-face | ||
| 5898 | ;; 'cperl-hash-face | ||
| 5899 | ;; "Face to use for hashes.")) | ||
| 5900 | ;;(or (boundp 'cperl-array-face) | ||
| 5901 | ;; (defconst cperl-array-face | ||
| 5902 | ;; 'cperl-array-face | ||
| 5903 | ;; "Face to use for arrays.")) | ||
| 5904 | (let ((background 'light)) | ||
| 5905 | (and (not (facep 'font-lock-constant-face)) | ||
| 5906 | (facep 'font-lock-reference-face) | ||
| 5907 | (copy-face 'font-lock-reference-face 'font-lock-constant-face)) | ||
| 5908 | (if (facep 'font-lock-type-face) nil | ||
| 5909 | (copy-face 'default 'font-lock-type-face) | ||
| 5910 | (cond | ||
| 5911 | ((eq background 'light) | ||
| 5912 | (set-face-foreground 'font-lock-type-face | ||
| 5913 | (if (x-color-defined-p "seagreen") | ||
| 5914 | "seagreen" | ||
| 5915 | "sea green"))) | ||
| 5916 | ((eq background 'dark) | ||
| 5917 | (set-face-foreground 'font-lock-type-face | ||
| 5918 | (if (x-color-defined-p "os2pink") | ||
| 5919 | "os2pink" | ||
| 5920 | "pink"))) | ||
| 5921 | (t | ||
| 5922 | (set-face-background 'font-lock-type-face "gray90")))) | ||
| 5923 | (if (facep 'cperl-nonoverridable-face) | ||
| 5924 | nil | ||
| 5925 | (copy-face 'font-lock-type-face 'cperl-nonoverridable-face) | ||
| 5926 | (cond | ||
| 5927 | ((eq background 'light) | ||
| 5928 | (set-face-foreground 'cperl-nonoverridable-face | ||
| 5929 | (if (x-color-defined-p "chartreuse3") | ||
| 5930 | "chartreuse3" | ||
| 5931 | "chartreuse"))) | ||
| 5932 | ((eq background 'dark) | ||
| 5933 | (set-face-foreground 'cperl-nonoverridable-face | ||
| 5934 | (if (x-color-defined-p "orchid1") | ||
| 5935 | "orchid1" | ||
| 5936 | "orange"))))) | ||
| 5937 | (if (facep 'font-lock-variable-name-face) nil | ||
| 5938 | (copy-face 'italic 'font-lock-variable-name-face)) | ||
| 5939 | (if (facep 'font-lock-constant-face) nil | ||
| 5940 | (copy-face 'italic 'font-lock-constant-face)))) | ||
| 5941 | (setq cperl-faces-init t)) | 5735 | (setq cperl-faces-init t)) |
| 5942 | (error (message "cperl-init-faces (ignored): %s" errs)))) | 5736 | (error (message "cperl-init-faces (ignored): %s" errs)))) |
| 5943 | 5737 | ||