aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorJoakim Verona2012-11-13 03:01:33 +0100
committerJoakim Verona2012-11-13 03:01:33 +0100
commit74fa27af7f4b50a6f5e2a378802b4c5edc11d044 (patch)
tree7030d55ecc2e06df59c08047b6f89e5b11a329dc /lisp/progmodes
parent2a4942ed0e4cca22145a0d973112454c410c3dd7 (diff)
parentb95a9c0cba301ef8f1920a1d123ccd6873c14a63 (diff)
downloademacs-74fa27af7f4b50a6f5e2a378802b4c5edc11d044.tar.gz
emacs-74fa27af7f4b50a6f5e2a378802b4c5edc11d044.zip
upstream
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/js.el35
-rw-r--r--lisp/progmodes/perl-mode.el121
-rw-r--r--lisp/progmodes/ruby-mode.el2
-rw-r--r--lisp/progmodes/sql.el47
4 files changed, 126 insertions, 79 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index d954cd53e0a..33ef7607671 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1823,22 +1823,31 @@ nil."
1823 1823
1824;;; Filling 1824;;; Filling
1825 1825
1826(defvar js--filling-paragraph nil)
1827
1828;; FIXME: Such redefinitions are bad style. We should try and use some other
1829;; way to get the same result.
1830(defadvice c-forward-sws (around js-fill-paragraph activate)
1831 (if js--filling-paragraph
1832 (setq ad-return-value (js--forward-syntactic-ws (ad-get-arg 0)))
1833 ad-do-it))
1834
1835(defadvice c-backward-sws (around js-fill-paragraph activate)
1836 (if js--filling-paragraph
1837 (setq ad-return-value (js--backward-syntactic-ws (ad-get-arg 0)))
1838 ad-do-it))
1839
1840(defadvice c-beginning-of-macro (around js-fill-paragraph activate)
1841 (if js--filling-paragraph
1842 (setq ad-return-value (js--beginning-of-macro (ad-get-arg 0)))
1843 ad-do-it))
1844
1826(defun js-c-fill-paragraph (&optional justify) 1845(defun js-c-fill-paragraph (&optional justify)
1827 "Fill the paragraph with `c-fill-paragraph'." 1846 "Fill the paragraph with `c-fill-paragraph'."
1828 (interactive "*P") 1847 (interactive "*P")
1829 ;; FIXME: Such redefinitions are bad style. We should try and use some other 1848 (let ((js--filling-paragraph t)
1830 ;; way to get the same result. 1849 (fill-paragraph-function 'c-fill-paragraph))
1831 (cl-letf (((symbol-function 'c-forward-sws) 1850 (c-fill-paragraph justify)))
1832 (lambda (&optional limit)
1833 (js--forward-syntactic-ws limit)))
1834 ((symbol-function 'c-backward-sws)
1835 (lambda (&optional limit)
1836 (js--backward-syntactic-ws limit)))
1837 ((symbol-function 'c-beginning-of-macro)
1838 (lambda (&optional limit)
1839 (js--beginning-of-macro limit))))
1840 (let ((fill-paragraph-function 'c-fill-paragraph))
1841 (c-fill-paragraph justify))))
1842 1851
1843;;; Type database and Imenu 1852;;; Type database and Imenu
1844 1853
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 3dd9a48bb33..d2f7fc7a059 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -1,4 +1,4 @@
1;;; perl-mode.el --- Perl code editing commands for GNU Emacs 1;;; perl-mode.el --- Perl code editing commands for GNU Emacs -*- coding: utf-8 -*-
2 2
3;; Copyright (C) 1990, 1994, 2001-2012 Free Software Foundation, Inc. 3;; Copyright (C) 1990, 1994, 2001-2012 Free Software Foundation, Inc.
4 4
@@ -102,11 +102,6 @@
102 102
103;;; Code: 103;;; Code:
104 104
105
106(defvar font-lock-comment-face)
107(defvar font-lock-doc-face)
108(defvar font-lock-string-face)
109
110(defgroup perl nil 105(defgroup perl nil
111 "Major mode for editing Perl code." 106 "Major mode for editing Perl code."
112 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) 107 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
@@ -119,16 +114,11 @@
119 114
120(defvar perl-mode-map 115(defvar perl-mode-map
121 (let ((map (make-sparse-keymap))) 116 (let ((map (make-sparse-keymap)))
122 (define-key map "{" 'perl-electric-terminator)
123 (define-key map "}" 'perl-electric-terminator)
124 (define-key map ";" 'perl-electric-terminator)
125 (define-key map ":" 'perl-electric-terminator)
126 (define-key map "\e\C-a" 'perl-beginning-of-function) 117 (define-key map "\e\C-a" 'perl-beginning-of-function)
127 (define-key map "\e\C-e" 'perl-end-of-function) 118 (define-key map "\e\C-e" 'perl-end-of-function)
128 (define-key map "\e\C-h" 'perl-mark-function) 119 (define-key map "\e\C-h" 'perl-mark-function)
129 (define-key map "\e\C-q" 'perl-indent-exp) 120 (define-key map "\e\C-q" 'perl-indent-exp)
130 (define-key map "\177" 'backward-delete-char-untabify) 121 (define-key map "\177" 'backward-delete-char-untabify)
131 (define-key map "\t" 'perl-indent-command)
132 map) 122 map)
133 "Keymap used in Perl mode.") 123 "Keymap used in Perl mode.")
134 124
@@ -158,16 +148,54 @@
158 148
159(defvar perl-imenu-generic-expression 149(defvar perl-imenu-generic-expression
160 '(;; Functions 150 '(;; Functions
161 (nil "^sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1) 151 (nil "^[ \t]*sub\\s-+\\([-A-Za-z0-9+_:]+\\)" 1)
162 ;;Variables 152 ;;Variables
163 ("Variables" "^\\(?:my\\|our\\)\\s-+\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1) 153 ("Variables" "^\\(?:my\\|our\\)\\s-+\\([$@%][-A-Za-z0-9+_:]+\\)\\s-*=" 1)
164 ("Packages" "^package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1) 154 ("Packages" "^[ \t]*package\\s-+\\([-A-Za-z0-9+_:]+\\);" 1)
165 ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1)) 155 ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1))
166 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.") 156 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.")
167 157
168;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and 158;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and
169;; Jim Campbell <jec@murzim.ca.boeing.com>. 159;; Jim Campbell <jec@murzim.ca.boeing.com>.
170 160
161(defcustom perl-prettify-symbols t
162 "If non-nil, some symbols will be displayed using Unicode chars."
163 :type 'boolean)
164
165(defconst perl--prettify-symbols-alist
166 '(;;("andalso" . ?∧) ("orelse" . ?∨) ("as" . ?≡)("not" . ?¬)
167 ;;("div" . ?÷) ("*" . ?×) ("o" . ?○)
168 ("->" . ?→)
169 ("=>" . ?⇒)
170 ;;("<-" . ?←) ("<>" . ?≠) (">=" . ?≥) ("<=" . ?≤) ("..." . ?⋯)
171 ("::" . ?∷)
172 ))
173
174(defun perl--font-lock-compose-symbol ()
175 "Compose a sequence of ascii chars into a symbol.
176Regexp match data 0 points to the chars."
177 ;; Check that the chars should really be composed into a symbol.
178 (let* ((start (match-beginning 0))
179 (end (match-end 0))
180 (syntaxes (if (eq (char-syntax (char-after start)) ?w)
181 '(?w) '(?. ?\\))))
182 (if (or (memq (char-syntax (or (char-before start) ?\ )) syntaxes)
183 (memq (char-syntax (or (char-after end) ?\ )) syntaxes)
184 (nth 8 (syntax-ppss)))
185 ;; No composition for you. Let's actually remove any composition
186 ;; we may have added earlier and which is now incorrect.
187 (remove-text-properties start end '(composition))
188 ;; That's a symbol alright, so add the composition.
189 (compose-region start end (cdr (assoc (match-string 0)
190 perl--prettify-symbols-alist)))))
191 ;; Return nil because we're not adding any face property.
192 nil)
193
194(defun perl--font-lock-symbols-keywords ()
195 (when perl-prettify-symbols
196 `((,(regexp-opt (mapcar 'car perl--prettify-symbols-alist) t)
197 (0 (perl--font-lock-compose-symbol))))))
198
171(defconst perl-font-lock-keywords-1 199(defconst perl-font-lock-keywords-1
172 '(;; What is this for? 200 '(;; What is this for?
173 ;;("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face) 201 ;;("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face)
@@ -190,32 +218,32 @@
190 "Subdued level highlighting for Perl mode.") 218 "Subdued level highlighting for Perl mode.")
191 219
192(defconst perl-font-lock-keywords-2 220(defconst perl-font-lock-keywords-2
193 (append perl-font-lock-keywords-1 221 (append
194 (list 222 perl-font-lock-keywords-1
195 ;; 223 `( ;; Fontify keywords, except those fontified otherwise.
196 ;; Fontify keywords, except those fontified otherwise. 224 ,(concat "\\<"
197 (concat "\\<" 225 (regexp-opt '("if" "until" "while" "elsif" "else" "unless"
198 (regexp-opt '("if" "until" "while" "elsif" "else" "unless" 226 "do" "dump" "for" "foreach" "exit" "die"
199 "do" "dump" "for" "foreach" "exit" "die" 227 "BEGIN" "END" "return" "exec" "eval") t)
200 "BEGIN" "END" "return" "exec" "eval") t) 228 "\\>")
201 "\\>") 229 ;;
202 ;; 230 ;; Fontify local and my keywords as types.
203 ;; Fontify local and my keywords as types. 231 ("\\<\\(local\\|my\\)\\>" . font-lock-type-face)
204 '("\\<\\(local\\|my\\)\\>" . font-lock-type-face) 232 ;;
205 ;; 233 ;; Fontify function, variable and file name references.
206 ;; Fontify function, variable and file name references. 234 ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
207 '("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face) 235 ;; Additionally underline non-scalar variables. Maybe this is a bad idea.
208 ;; Additionally underline non-scalar variables. Maybe this is a bad idea. 236 ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
209 ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face) 237 ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
210 '("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face) 238 ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
211 '("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
212 (2 (cons font-lock-variable-name-face '(underline)))) 239 (2 (cons font-lock-variable-name-face '(underline))))
213 '("<\\(\\sw+\\)>" 1 font-lock-constant-face) 240 ("<\\(\\sw+\\)>" 1 font-lock-constant-face)
214 ;; 241 ;;
215 ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'. 242 ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
216 '("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?" 243 ("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?"
217 (1 font-lock-keyword-face) (2 font-lock-constant-face nil t)) 244 (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
218 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-constant-face))) 245 ("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-constant-face)
246 ,@(perl--font-lock-symbols-keywords)))
219 "Gaudy level highlighting for Perl mode.") 247 "Gaudy level highlighting for Perl mode.")
220 248
221(defvar perl-font-lock-keywords perl-font-lock-keywords-1 249(defvar perl-font-lock-keywords perl-font-lock-keywords-1
@@ -543,8 +571,10 @@ create a new comment."
543 571
544(defun perl-outline-level () 572(defun perl-outline-level ()
545 (cond 573 (cond
546 ((looking-at "package\\s-") 0) 574 ((looking-at "[ \t]*\\(package\\)\\s-")
547 ((looking-at "sub\\s-") 1) 575 (- (match-beginning 1) (match-beginning 0)))
576 ((looking-at "[ \t]*s\\(ub\\)\\s-")
577 (- (match-beginning 1) (match-beginning 0)))
548 ((looking-at "=head[0-9]") (- (char-before (match-end 0)) ?0)) 578 ((looking-at "=head[0-9]") (- (char-before (match-end 0)) ?0))
549 ((looking-at "=cut") 1) 579 ((looking-at "=cut") 1)
550 (t 3))) 580 (t 3)))
@@ -621,6 +651,11 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'."
621 #'perl-syntax-propertize-function) 651 #'perl-syntax-propertize-function)
622 (add-hook 'syntax-propertize-extend-region-functions 652 (add-hook 'syntax-propertize-extend-region-functions
623 #'syntax-propertize-multiline 'append 'local) 653 #'syntax-propertize-multiline 'append 'local)
654 ;; Electricity.
655 ;; FIXME: setup electric-layout-rules.
656 (set (make-local-variable 'electric-indent-chars)
657 (append '(?\{ ?\} ?\; ?\:) electric-indent-chars))
658 (add-hook 'electric-indent-functions #'perl-electric-noindent-p nil t)
624 ;; Tell imenu how to handle Perl. 659 ;; Tell imenu how to handle Perl.
625 (set (make-local-variable 'imenu-generic-expression) 660 (set (make-local-variable 'imenu-generic-expression)
626 perl-imenu-generic-expression) 661 perl-imenu-generic-expression)
@@ -637,7 +672,11 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'."
637 0 ;Existing comment at bol stays there. 672 0 ;Existing comment at bol stays there.
638 comment-column)) 673 comment-column))
639 674
640(defalias 'electric-perl-terminator 'perl-electric-terminator) 675(define-obsolete-function-alias 'electric-perl-terminator
676 'perl-electric-terminator "22.1")
677(defun perl-electric-noindent-p (char)
678 (unless (eolp) 'no-indent))
679
641(defun perl-electric-terminator (arg) 680(defun perl-electric-terminator (arg)
642 "Insert character and maybe adjust indentation. 681 "Insert character and maybe adjust indentation.
643If at end-of-line, and not in a comment or a quote, correct the indentation." 682If at end-of-line, and not in a comment or a quote, correct the indentation."
@@ -661,6 +700,7 @@ If at end-of-line, and not in a comment or a quote, correct the indentation."
661 (perl-indent-line) 700 (perl-indent-line)
662 (delete-char -1)))) 701 (delete-char -1))))
663 (self-insert-command (prefix-numeric-value arg))) 702 (self-insert-command (prefix-numeric-value arg)))
703(make-obsolete 'perl-electric-terminator 'electric-indent-mode "24.4")
664 704
665;; not used anymore, but may be useful someday: 705;; not used anymore, but may be useful someday:
666;;(defun perl-inside-parens-p () 706;;(defun perl-inside-parens-p ()
@@ -744,6 +784,7 @@ following list:
744 (t 784 (t
745 (message "Use backslash to quote # characters.") 785 (message "Use backslash to quote # characters.")
746 (ding t))))))))) 786 (ding t)))))))))
787(make-obsolete 'perl-indent-command 'indent-according-to-mode "24.4")
747 788
748(defun perl-indent-line (&optional nochange parse-start) 789(defun perl-indent-line (&optional nochange parse-start)
749 "Indent current line as Perl code. 790 "Indent current line as Perl code.
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 84cf7308d75..c9bfcefb748 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1638,6 +1638,8 @@ The variable `ruby-indent-level' controls the amount of indentation.
1638 1638
1639;;;###autoload 1639;;;###autoload
1640(add-to-list 'auto-mode-alist (cons (purecopy "\\.rb\\'") 'ruby-mode)) 1640(add-to-list 'auto-mode-alist (cons (purecopy "\\.rb\\'") 'ruby-mode))
1641;;;###autoload
1642(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
1641 1643
1642;;;###autoload 1644;;;###autoload
1643(dolist (name (list "ruby" "rbx" "jruby" "ruby1.9" "ruby1.8")) 1645(dolist (name (list "ruby" "rbx" "jruby" "ruby1.9" "ruby1.8"))
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 3d5abc4df62..64b87d9e436 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -2802,8 +2802,12 @@ each line with INDENT."
2802 doc)) 2802 doc))
2803 2803
2804;;;###autoload 2804;;;###autoload
2805(defun sql-help () 2805(eval
2806 "Show short help for the SQL modes. 2806 ;; FIXME: This dynamic-docstring-function trick doesn't work for byte-compiled
2807 ;; functions, because of the lazy-loading of docstrings, which strips away
2808 ;; text properties.
2809 '(defun sql-help ()
2810 #("Show short help for the SQL modes.
2807 2811
2808Use an entry function to open an interactive SQL buffer. This buffer is 2812Use an entry function to open an interactive SQL buffer. This buffer is
2809usually named `*SQL*'. The name of the major mode is SQLi. 2813usually named `*SQL*'. The name of the major mode is SQLi.
@@ -2834,32 +2838,23 @@ anything. The name of the major mode is SQL.
2834In this SQL buffer (SQL mode), you can send the region or the entire 2838In this SQL buffer (SQL mode), you can send the region or the entire
2835buffer to the interactive SQL buffer (SQLi mode). The results are 2839buffer to the interactive SQL buffer (SQLi mode). The results are
2836appended to the SQLi buffer without disturbing your SQL buffer." 2840appended to the SQLi buffer without disturbing your SQL buffer."
2841 0 1 (dynamic-docstring-function sql--make-help-docstring))
2837 (interactive) 2842 (interactive)
2843 (describe-function 'sql-help)))
2838 2844
2839 ;; Insert references to loaded products into the help buffer string 2845(defun sql--make-help-docstring (doc _fun)
2840 (let ((doc (documentation 'sql-help t)) 2846 "Insert references to loaded products into the help buffer string."
2841 changedp) 2847
2842 (setq changedp nil) 2848 ;; Insert FREE software list
2843 2849 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*\n" doc 0)
2844 ;; Insert FREE software list 2850 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) t)
2845 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*\n" doc 0) 2851 t t doc 0)))
2846 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) t) 2852
2847 t t doc 0) 2853 ;; Insert non-FREE software list
2848 changedp t)) 2854 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*\n" doc 0)
2849 2855 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) nil)
2850 ;; Insert non-FREE software list 2856 t t doc 0)))
2851 (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*\n" doc 0) 2857 doc)
2852 (setq doc (replace-match (sql-help-list-products (match-string 1 doc) nil)
2853 t t doc 0)
2854 changedp t))
2855
2856 ;; If we changed the help text, save the change so that the help
2857 ;; sub-system will see it
2858 (when changedp
2859 (put 'sql-help 'function-documentation doc)))
2860
2861 ;; Call help on this function
2862 (describe-function 'sql-help))
2863 2858
2864(defun sql-read-passwd (prompt &optional default) 2859(defun sql-read-passwd (prompt &optional default)
2865 "Read a password using PROMPT. Optional DEFAULT is password to start with." 2860 "Read a password using PROMPT. Optional DEFAULT is password to start with."