diff options
| author | Stefan Monnier | 2013-05-24 15:37:55 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-05-24 15:37:55 -0400 |
| commit | 650cff3d874e68a8aa80cbdb71ff9f48e10d1cb6 (patch) | |
| tree | ccd37f50a1ca75b81b3c602937d8be1a71caa0b2 /lisp/progmodes | |
| parent | 9631677d730a314f55378f5da6734db521f8130d (diff) | |
| download | emacs-650cff3d874e68a8aa80cbdb71ff9f48e10d1cb6.tar.gz emacs-650cff3d874e68a8aa80cbdb71ff9f48e10d1cb6.zip | |
* lisp/emacs-lisp/smie.el (smie-auto-fill): Rework to be more robust.
(smie-setup): Use add-function to set it.
* lisp/progmodes/octave.el (octave-smie-rules): Return nil rather than
0 after a semi-colon; it works better for smie-auto-fill.
(octave--indent-new-comment-line): New function.
(octave-indent-new-comment-line): Use it (indirectly).
(octave-mode): Don't disable smie-auto-fill. Use add-function to
modify comment-line-break-function.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/octave.el | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 62bef6dfdea..243e3198584 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el | |||
| @@ -438,7 +438,7 @@ Non-nil means always go to the next Octave code line after sending." | |||
| 438 | (smie-rule-parent octave-block-offset) | 438 | (smie-rule-parent octave-block-offset) |
| 439 | ;; For (invalid) code between switch and case. | 439 | ;; For (invalid) code between switch and case. |
| 440 | ;; (if (smie-parent-p "switch") 4) | 440 | ;; (if (smie-parent-p "switch") 4) |
| 441 | 0)))) | 441 | nil)))) |
| 442 | 442 | ||
| 443 | (defun octave-indent-comment () | 443 | (defun octave-indent-comment () |
| 444 | "A function for `smie-indent-functions' (which see)." | 444 | "A function for `smie-indent-functions' (which see)." |
| @@ -552,11 +552,10 @@ definitions can also be stored in files and used in batch mode." | |||
| 552 | (setq-local paragraph-ignore-fill-prefix t) | 552 | (setq-local paragraph-ignore-fill-prefix t) |
| 553 | (setq-local fill-paragraph-function 'octave-fill-paragraph) | 553 | (setq-local fill-paragraph-function 'octave-fill-paragraph) |
| 554 | 554 | ||
| 555 | ;; Use `smie-auto-fill' after fixing bug#14381. | ||
| 556 | (setq-local normal-auto-fill-function 'do-auto-fill) | ||
| 557 | (setq-local fill-nobreak-predicate | 555 | (setq-local fill-nobreak-predicate |
| 558 | (lambda () (eq (octave-in-string-p) ?'))) | 556 | (lambda () (eq (octave-in-string-p) ?'))) |
| 559 | (setq-local comment-line-break-function #'octave-indent-new-comment-line) | 557 | (add-function :around (local 'comment-line-break-function) |
| 558 | #'octave--indent-new-comment-line) | ||
| 560 | 559 | ||
| 561 | (setq font-lock-defaults '(octave-font-lock-keywords)) | 560 | (setq font-lock-defaults '(octave-font-lock-keywords)) |
| 562 | 561 | ||
| @@ -1112,11 +1111,16 @@ q: Don't fix\n" func file)) | |||
| 1112 | ;;; Indentation | 1111 | ;;; Indentation |
| 1113 | 1112 | ||
| 1114 | (defun octave-indent-new-comment-line (&optional soft) | 1113 | (defun octave-indent-new-comment-line (&optional soft) |
| 1114 | ;; FIXME: C-M-j should probably be bound globally to a function like | ||
| 1115 | ;; this one. | ||
| 1115 | "Break Octave line at point, continuing comment if within one. | 1116 | "Break Octave line at point, continuing comment if within one. |
| 1116 | Insert `octave-continuation-string' before breaking the line | 1117 | Insert `octave-continuation-string' before breaking the line |
| 1117 | unless inside a list. Signal an error if within a single-quoted | 1118 | unless inside a list. Signal an error if within a single-quoted |
| 1118 | string." | 1119 | string." |
| 1119 | (interactive) | 1120 | (interactive) |
| 1121 | (funcall comment-line-break-function soft)) | ||
| 1122 | |||
| 1123 | (defun octave--indent-new-comment-line (orig &rest args) | ||
| 1120 | (cond | 1124 | (cond |
| 1121 | ((octave-in-comment-p) nil) | 1125 | ((octave-in-comment-p) nil) |
| 1122 | ((eq (octave-in-string-p) ?') | 1126 | ((eq (octave-in-string-p) ?') |
| @@ -1128,7 +1132,7 @@ string." | |||
| 1128 | (unless (and (cadr (syntax-ppss)) | 1132 | (unless (and (cadr (syntax-ppss)) |
| 1129 | (eq (char-after (cadr (syntax-ppss))) ?\()) | 1133 | (eq (char-after (cadr (syntax-ppss))) ?\()) |
| 1130 | (insert " " octave-continuation-string)))) | 1134 | (insert " " octave-continuation-string)))) |
| 1131 | (indent-new-comment-line soft) | 1135 | (apply orig args) |
| 1132 | (indent-according-to-mode)) | 1136 | (indent-according-to-mode)) |
| 1133 | 1137 | ||
| 1134 | (define-obsolete-function-alias | 1138 | (define-obsolete-function-alias |