aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2008-12-11 11:03:42 +0000
committerJuanma Barranquero2008-12-11 11:03:42 +0000
commitee61fe97ea044bd246c666f37c961c5d298900c1 (patch)
tree69e0879ecce3fbc9adc48f941d2590554fe92c14
parentc160ca6d8ef512e6c1fad4085ae764eae68ded01 (diff)
downloademacs-ee61fe97ea044bd246c666f37c961c5d298900c1.tar.gz
emacs-ee61fe97ea044bd246c666f37c961c5d298900c1.zip
* progmodes/ruby-mode.el (ruby-mode-abbrev-table, ruby-mode-map)
(ruby-mode-syntax-table, ruby-indent-tabs-mode, ruby-indent-level) (ruby-mode-variables, ruby-indent-line, ruby-indent-size) (ruby-calculate-indent, ruby-electric-brace, ruby-beginning-of-defun) (ruby-here-doc-beg-syntax, ruby-here-doc-end-syntax) (ruby-font-lock-syntax-table, ruby-font-lock-keywords) (ruby-end-of-defun, ruby-move-to-block, ruby-forward-sexp) (ruby-backward-sexp, ruby-add-log-current-method) (ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax) (ruby-in-here-doc-p, ruby-mode): Fix typos in docstrings. (ruby-deep-indent-paren): Doc fix. (ruby-insert-encoding-magic-comment): Remove * from docstring. (ruby-here-doc-find-end): Reflow docstring.
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/progmodes/ruby-mode.el66
2 files changed, 51 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e69634f9dee..fef3cfa9f67 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,4 +1,20 @@
12008-12-11 Stephen Berman <Stephen.Berman@rub.de> 12008-12-11 Juanma Barranquero <lekktu@gmail.com>
2
3 * progmodes/ruby-mode.el (ruby-mode-abbrev-table, ruby-mode-map)
4 (ruby-mode-syntax-table, ruby-indent-tabs-mode, ruby-indent-level)
5 (ruby-mode-variables, ruby-indent-line, ruby-indent-size)
6 (ruby-calculate-indent, ruby-electric-brace, ruby-beginning-of-defun)
7 (ruby-here-doc-beg-syntax, ruby-here-doc-end-syntax)
8 (ruby-font-lock-syntax-table, ruby-font-lock-keywords)
9 (ruby-end-of-defun, ruby-move-to-block, ruby-forward-sexp)
10 (ruby-backward-sexp, ruby-add-log-current-method)
11 (ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
12 (ruby-in-here-doc-p, ruby-mode): Fix typos in docstrings.
13 (ruby-deep-indent-paren): Doc fix.
14 (ruby-insert-encoding-magic-comment): Remove * from docstring.
15 (ruby-here-doc-find-end): Reflow docstring.
16
172008-12-11 Stephen Berman <Stephen.Berman@rub.de>
2 18
3 * dired.el (dired-pop-to-buffer): Use fit-window-to-buffer when 19 * dired.el (dired-pop-to-buffer): Use fit-window-to-buffer when
4 dired-shrink-to-fit is non-nil. (Bug#1488) 20 dired-shrink-to-fit is non-nil. (Bug#1488)
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 1165d306b01..d366f4c6d4a 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -149,7 +149,7 @@ This should only be called after matching against `ruby-here-doc-end-re'."
149 "Regexp to match symbols.") 149 "Regexp to match symbols.")
150 150
151(defvar ruby-mode-abbrev-table nil 151(defvar ruby-mode-abbrev-table nil
152 "Abbrev table in use in ruby-mode buffers.") 152 "Abbrev table in use in Ruby mode buffers.")
153 153
154(define-abbrev-table 'ruby-mode-abbrev-table ()) 154(define-abbrev-table 'ruby-mode-abbrev-table ())
155 155
@@ -170,7 +170,7 @@ This should only be called after matching against `ruby-here-doc-end-re'."
170 (define-key map (kbd "C-j") 'reindent-then-newline-and-indent) 170 (define-key map (kbd "C-j") 'reindent-then-newline-and-indent)
171 (define-key map (kbd "C-m") 'newline) 171 (define-key map (kbd "C-m") 'newline)
172 map) 172 map)
173 "Keymap used in ruby-mode.") 173 "Keymap used in Ruby mode.")
174 174
175(defvar ruby-mode-syntax-table 175(defvar ruby-mode-syntax-table
176 (let ((table (make-syntax-table))) 176 (let ((table (make-syntax-table)))
@@ -201,14 +201,14 @@ This should only be called after matching against `ruby-here-doc-end-re'."
201 (modify-syntax-entry ?\[ "(]" table) 201 (modify-syntax-entry ?\[ "(]" table)
202 (modify-syntax-entry ?\] ")[" table) 202 (modify-syntax-entry ?\] ")[" table)
203 table) 203 table)
204 "Syntax table to use in ruby-mode.") 204 "Syntax table to use in Ruby mode.")
205 205
206(defcustom ruby-indent-tabs-mode nil 206(defcustom ruby-indent-tabs-mode nil
207 "Indentation can insert tabs in ruby mode if this is non-nil." 207 "Indentation can insert tabs in Ruby mode if this is non-nil."
208 :type 'boolean :group 'ruby) 208 :type 'boolean :group 'ruby)
209 209
210(defcustom ruby-indent-level 2 210(defcustom ruby-indent-level 2
211 "Indentation of ruby statements." 211 "Indentation of Ruby statements."
212 :type 'integer :group 'ruby) 212 :type 'integer :group 'ruby)
213 213
214(defcustom ruby-comment-column 32 214(defcustom ruby-comment-column 32
@@ -221,7 +221,8 @@ Also ignores spaces after parenthesis when 'space."
221 :group 'ruby) 221 :group 'ruby)
222 222
223(defcustom ruby-deep-indent-paren '(?\( ?\[ ?\] t) 223(defcustom ruby-deep-indent-paren '(?\( ?\[ ?\] t)
224 "Deep indent lists in parenthesis when non-nil. t means continuous line. 224 "Deep indent lists in parenthesis when non-nil.
225The value t means continuous line.
225Also ignores spaces after parenthesis when 'space." 226Also ignores spaces after parenthesis when 'space."
226 :group 'ruby) 227 :group 'ruby)
227 228
@@ -234,7 +235,7 @@ Also ignores spaces after parenthesis when 'space."
234 :group 'ruby) 235 :group 'ruby)
235 236
236(defcustom ruby-insert-encoding-magic-comment t 237(defcustom ruby-insert-encoding-magic-comment t
237 "*Insert a magic emacs 'coding' comment upon save if this is non-nil." 238 "Insert a magic Emacs 'coding' comment upon save if this is non-nil."
238 :type 'boolean :group 'ruby) 239 :type 'boolean :group 'ruby)
239 240
240(defcustom ruby-use-encoding-map t 241(defcustom ruby-use-encoding-map t
@@ -297,7 +298,7 @@ Also ignores spaces after parenthesis when 'space."
297 (>= (nth 2 state) 0) (< (point) end))))) 298 (>= (nth 2 state) 0) (< (point) end)))))
298 299
299(defun ruby-mode-variables () 300(defun ruby-mode-variables ()
300 "Set up initial buffer-local variables for ruby-mode." 301 "Set up initial buffer-local variables for Ruby mode."
301 (set-syntax-table ruby-mode-syntax-table) 302 (set-syntax-table ruby-mode-syntax-table)
302 (setq local-abbrev-table ruby-mode-abbrev-table) 303 (setq local-abbrev-table ruby-mode-abbrev-table)
303 (setq indent-tabs-mode ruby-indent-tabs-mode) 304 (setq indent-tabs-mode ruby-indent-tabs-mode)
@@ -357,7 +358,7 @@ Also ignores spaces after parenthesis when 'space."
357 (current-column))) 358 (current-column)))
358 359
359(defun ruby-indent-line (&optional flag) 360(defun ruby-indent-line (&optional flag)
360 "Correct the indentation of the current ruby line." 361 "Correct the indentation of the current Ruby line."
361 (interactive) 362 (interactive)
362 (ruby-indent-to (ruby-calculate-indent))) 363 (ruby-indent-to (ruby-calculate-indent)))
363 364
@@ -449,7 +450,7 @@ and `\\' when preceded by `?'."
449 ((error "unterminated string"))))) 450 ((error "unterminated string")))))
450 451
451(defun ruby-deep-indent-paren-p (c) 452(defun ruby-deep-indent-paren-p (c)
452 "TODO: document." 453 "TODO: document."
453 (cond ((listp ruby-deep-indent-paren) 454 (cond ((listp ruby-deep-indent-paren)
454 (let ((deep (assoc c ruby-deep-indent-paren))) 455 (let ((deep (assoc c ruby-deep-indent-paren)))
455 (cond (deep 456 (cond (deep
@@ -460,7 +461,7 @@ and `\\' when preceded by `?'."
460 ((eq c ?\( ) ruby-deep-arglist))) 461 ((eq c ?\( ) ruby-deep-arglist)))
461 462
462(defun ruby-parse-partial (&optional end in-string nest depth pcol indent) 463(defun ruby-parse-partial (&optional end in-string nest depth pcol indent)
463 "TODO: document throughout function body." 464 "TODO: document throughout function body."
464 (or depth (setq depth 0)) 465 (or depth (setq depth 0))
465 (or indent (setq indent 0)) 466 (or indent (setq indent 0))
466 (when (re-search-forward ruby-delimiter end 'move) 467 (when (re-search-forward ruby-delimiter end 'move)
@@ -684,11 +685,11 @@ and `\\' when preceded by `?'."
684 ))) 685 )))
685 686
686(defun ruby-indent-size (pos nest) 687(defun ruby-indent-size (pos nest)
687 "Returns the indentation level in spaces NEST levels deeper than POS." 688 "Return the indentation level in spaces NEST levels deeper than POS."
688 (+ pos (* (or nest 1) ruby-indent-level))) 689 (+ pos (* (or nest 1) ruby-indent-level)))
689 690
690(defun ruby-calculate-indent (&optional parse-start) 691(defun ruby-calculate-indent (&optional parse-start)
691 "Returns the proper indentation level of the current line." 692 "Return the proper indentation level of the current line."
692 ;; TODO: Document body 693 ;; TODO: Document body
693 (save-excursion 694 (save-excursion
694 (beginning-of-line) 695 (beginning-of-line)
@@ -746,7 +747,7 @@ and `\\' when preceded by `?'."
746 (setq indent (ruby-indent-size (current-column) (nth 2 state)))) 747 (setq indent (ruby-indent-size (current-column) (nth 2 state))))
747 (t 748 (t
748 (setq indent (+ (current-column) ruby-indent-level))))) 749 (setq indent (+ (current-column) ruby-indent-level)))))
749 750
750 ((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest 751 ((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest
751 (setq indent (ruby-indent-size (current-column) (nth 2 state))))) 752 (setq indent (ruby-indent-size (current-column) (nth 2 state)))))
752 (when indent 753 (when indent
@@ -851,7 +852,7 @@ and `\\' when preceded by `?'."
851 indent)))) 852 indent))))
852 853
853(defun ruby-electric-brace (arg) 854(defun ruby-electric-brace (arg)
854 "Inserts a brace and re-indents the current line." 855 "Insert a brace and re-indent the current line."
855 (interactive "P") 856 (interactive "P")
856 (self-insert-command (prefix-numeric-value arg)) 857 (self-insert-command (prefix-numeric-value arg))
857 (ruby-indent-line t)) 858 (ruby-indent-line t))
@@ -859,7 +860,7 @@ and `\\' when preceded by `?'."
859;; TODO: Why isn't one ruby-*-of-defun written in terms of the other? 860;; TODO: Why isn't one ruby-*-of-defun written in terms of the other?
860(defun ruby-beginning-of-defun (&optional arg) 861(defun ruby-beginning-of-defun (&optional arg)
861 "Move backward to the beginning of the current top-level defun. 862 "Move backward to the beginning of the current top-level defun.
862With ARG, move backward multiple defuns. Negative ARG means 863With ARG, move backward multiple defuns. Negative ARG means
863move forward." 864move forward."
864 (interactive "p") 865 (interactive "p")
865 (and (re-search-backward (concat "^\\(" ruby-block-beg-re "\\)\\b") 866 (and (re-search-backward (concat "^\\(" ruby-block-beg-re "\\)\\b")
@@ -868,7 +869,7 @@ move forward."
868 869
869(defun ruby-end-of-defun (&optional arg) 870(defun ruby-end-of-defun (&optional arg)
870 "Move forward to the end of the current top-level defun. 871 "Move forward to the end of the current top-level defun.
871With ARG, move forward multiple defuns. Negative ARG means 872With ARG, move forward multiple defuns. Negative ARG means
872move backward." 873move backward."
873 (interactive "p") 874 (interactive "p")
874 (and (re-search-forward (concat "^\\(" ruby-block-end-re "\\)\\($\\|\\b[^_]\\)") 875 (and (re-search-forward (concat "^\\(" ruby-block-end-re "\\)\\($\\|\\b[^_]\\)")
@@ -886,7 +887,7 @@ move backward."
886 (beginning-of-line))) 887 (beginning-of-line)))
887 888
888(defun ruby-move-to-block (n) 889(defun ruby-move-to-block (n)
889 "Moves to the beginning (N < 0) or the end (N > 0) of the current block 890 "Move to the beginning (N < 0) or the end (N > 0) of the current block
890or blocks containing the current block." 891or blocks containing the current block."
891 ;; TODO: Make this work for n > 1, 892 ;; TODO: Make this work for n > 1,
892 ;; make it not loop for n = 0, 893 ;; make it not loop for n = 0,
@@ -935,7 +936,7 @@ With ARG, move out of multiple blocks."
935 936
936(defun ruby-forward-sexp (&optional arg) 937(defun ruby-forward-sexp (&optional arg)
937 "Move forward across one balanced expression (sexp). 938 "Move forward across one balanced expression (sexp).
938With ARG, do it many times. Negative ARG means move backward." 939With ARG, do it many times. Negative ARG means move backward."
939 ;; TODO: Document body 940 ;; TODO: Document body
940 (interactive "p") 941 (interactive "p")
941 (if (and (numberp arg) (< arg 0)) 942 (if (and (numberp arg) (< arg 0))
@@ -977,7 +978,7 @@ With ARG, do it many times. Negative ARG means move backward."
977 978
978(defun ruby-backward-sexp (&optional arg) 979(defun ruby-backward-sexp (&optional arg)
979 "Move backward across one balanced expression (sexp). 980 "Move backward across one balanced expression (sexp).
980With ARG, do it many times. Negative ARG means move forward." 981With ARG, do it many times. Negative ARG means move forward."
981 ;; TODO: Document body 982 ;; TODO: Document body
982 (interactive "p") 983 (interactive "p")
983 (if (and (numberp arg) (< arg 0)) 984 (if (and (numberp arg) (< arg 0))
@@ -1055,7 +1056,7 @@ are signalled if a balanced expression isn't found."
1055 (set-marker here nil)))) 1056 (set-marker here nil))))
1056 1057
1057(defun ruby-add-log-current-method () 1058(defun ruby-add-log-current-method ()
1058 "Returns the current method name as a string. 1059 "Return the current method name as a string.
1059This string includes all namespaces. 1060This string includes all namespaces.
1060 1061
1061For example: 1062For example:
@@ -1165,10 +1166,10 @@ See `add-log-current-defun-function'."
1165 ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re)) 1166 ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re))
1166 (ruby-here-doc-beg-syntax)) 1167 (ruby-here-doc-beg-syntax))
1167 (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax))) 1168 (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax)))
1168 "Syntactic keywords for ruby-mode. See `font-lock-syntactic-keywords'.") 1169 "Syntactic keywords for Ruby mode. See `font-lock-syntactic-keywords'.")
1169 1170
1170(defun ruby-comment-beg-syntax () 1171(defun ruby-comment-beg-syntax ()
1171 "Returns the syntax cell for a the first character of a =begin. 1172 "Return the syntax cell for a the first character of a =begin.
1172See the definition of `ruby-font-lock-syntactic-keywords'. 1173See the definition of `ruby-font-lock-syntactic-keywords'.
1173 1174
1174This returns a comment-delimiter cell as long as the =begin 1175This returns a comment-delimiter cell as long as the =begin
@@ -1205,7 +1206,7 @@ isn't in a string or another comment."
1205 t))) 1206 t)))
1206 1207
1207(defun ruby-in-here-doc-p () 1208(defun ruby-in-here-doc-p ()
1208 "Returns whether or not the point is in a heredoc." 1209 "Return whether or not the point is in a heredoc."
1209 (save-excursion 1210 (save-excursion
1210 (let ((old-point (point)) (case-fold-search nil)) 1211 (let ((old-point (point)) (case-fold-search nil))
1211 (beginning-of-line) 1212 (beginning-of-line)
@@ -1216,9 +1217,9 @@ isn't in a string or another comment."
1216 (throw 'found-beg t))))))) 1217 (throw 'found-beg t)))))))
1217 1218
1218(defun ruby-here-doc-find-end (&optional limit) 1219(defun ruby-here-doc-find-end (&optional limit)
1219 "Expects the point to be on a line with one or more heredoc 1220 "Expects the point to be on a line with one or more heredoc openers.
1220openers. Returns the buffer position at which all heredocs on the 1221Returns the buffer position at which all heredocs on the line
1221line are terminated, or nil if they aren't terminated before the 1222are terminated, or nil if they aren't terminated before the
1222buffer position `limit' or the end of the buffer." 1223buffer position `limit' or the end of the buffer."
1223 (save-excursion 1224 (save-excursion
1224 (beginning-of-line) 1225 (beginning-of-line)
@@ -1244,7 +1245,7 @@ buffer position `limit' or the end of the buffer."
1244 (point))))) 1245 (point)))))
1245 1246
1246(defun ruby-here-doc-beg-syntax () 1247(defun ruby-here-doc-beg-syntax ()
1247 "Returns the syntax cell for a line that may begin a heredoc. 1248 "Return the syntax cell for a line that may begin a heredoc.
1248See the definition of `ruby-font-lock-syntactic-keywords'. 1249See the definition of `ruby-font-lock-syntactic-keywords'.
1249 1250
1250This sets the syntax cell for the newline ending the line 1251This sets the syntax cell for the newline ending the line
@@ -1257,7 +1258,7 @@ heredocs are started on one line are handled correctly."
1257 (string-to-syntax "|")))) 1258 (string-to-syntax "|"))))
1258 1259
1259(defun ruby-here-doc-end-syntax () 1260(defun ruby-here-doc-end-syntax ()
1260 "Returns the syntax cell for a line that may end a heredoc. 1261 "Return the syntax cell for a line that may end a heredoc.
1261See the definition of `ruby-font-lock-syntactic-keywords'." 1262See the definition of `ruby-font-lock-syntactic-keywords'."
1262 (let ((pss (syntax-ppss)) (case-fold-search nil)) 1263 (let ((pss (syntax-ppss)) (case-fold-search nil))
1263 ;; If we aren't in a string, we definitely aren't ending a heredoc, 1264 ;; If we aren't in a string, we definitely aren't ending a heredoc,
@@ -1287,7 +1288,7 @@ See the definition of `ruby-font-lock-syntactic-keywords'."
1287 (let ((tbl (copy-syntax-table ruby-mode-syntax-table))) 1288 (let ((tbl (copy-syntax-table ruby-mode-syntax-table)))
1288 (modify-syntax-entry ?_ "w" tbl) 1289 (modify-syntax-entry ?_ "w" tbl)
1289 tbl) 1290 tbl)
1290 "The syntax table to use for fontifying ruby-mode buffers. 1291 "The syntax table to use for fontifying Ruby mode buffers.
1291See `font-lock-syntax-table'.") 1292See `font-lock-syntax-table'.")
1292 1293
1293(defconst ruby-font-lock-keywords 1294(defconst ruby-font-lock-keywords
@@ -1369,7 +1370,7 @@ See `font-lock-syntax-table'.")
1369 ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)" 1370 ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)"
1370 ; 0 font-lock-warning-face) 1371 ; 0 font-lock-warning-face)
1371 ) 1372 )
1372 "Additional expressions to highlight in ruby mode.") 1373 "Additional expressions to highlight in Ruby mode.")
1373 1374
1374;;;###autoload 1375;;;###autoload
1375(defun ruby-mode () 1376(defun ruby-mode ()
@@ -1378,7 +1379,8 @@ See `font-lock-syntax-table'.")
1378class, module, def, if, while, for, do, and case statements, taking 1379class, module, def, if, while, for, do, and case statements, taking
1379nesting into account. 1380nesting into account.
1380 1381
1381The variable ruby-indent-level controls the amount of indentation. 1382The variable `ruby-indent-level' controls the amount of indentation.
1383
1382\\{ruby-mode-map}" 1384\\{ruby-mode-map}"
1383 (interactive) 1385 (interactive)
1384 (kill-all-local-variables) 1386 (kill-all-local-variables)