emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 93c0f51: Handle TeX comments when making new para


From: Karl Fogel
Subject: [Emacs-diffs] emacs-25 93c0f51: Handle TeX comments when making new paragraph
Date: Sat, 26 Nov 2016 05:44:52 +0000 (UTC)

branch: emacs-25
commit 93c0f5126a50a0b1267ba74c444701af9ad46dc6
Author: Karl Fogel <address@hidden>
Commit: Karl Fogel <address@hidden>

    Handle TeX comments when making new paragraph
    
    * lisp/textmodes/tex-mode.el (tex-handle-newline): New function.
      Handle comment case directly, and dispatch to `tex-terminate-paragraph'
      for original behavior in non-comment case.
      (tex-mode-map): Bind above to C-j, replacing `tex-terminate-paragraph'.
---
 lisp/textmodes/tex-mode.el |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 8545a09..ea7fbf8 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -869,7 +869,7 @@ START is the position of the \\ and DELIM is the delimiter 
char."
     (set-keymap-parent map text-mode-map)
     (tex-define-common-keys map)
     (define-key map "\"" 'tex-insert-quote)
-    (define-key map "\n" 'tex-terminate-paragraph)
+    (define-key map "\n" 'tex-handle-newline)
     (define-key map "\M-\r" 'latex-insert-item)
     (define-key map "\C-c}" 'up-list)
     (define-key map "\C-c{" 'tex-insert-braces)
@@ -1459,6 +1459,17 @@ area if a mismatch is found."
     (if failure-point (goto-char failure-point))
     (not failure-point)))
 
+(defun tex-handle-newline (inhibit-validation)
+  "Break a TeX paragraph with two newlines, or continue a comment.
+If not in a comment, insert two newlines, breaking a paragraph for TeX,
+and check for mismatched braces or $s in the paragraph being terminated
+unless prefix arg INHIBIT-VALIDATION is non-nil to inhibit the checking.
+Otherwise (in a comment), just insert a single continued comment line."
+  (interactive "*P")
+  (if (nth 4 (syntax-ppss)) ; non-nil if point is in a TeX comment
+      (comment-indent-new-line)
+    (tex-terminate-paragraph inhibit-validation)))
+
 (defun tex-terminate-paragraph (inhibit-validation)
   "Insert two newlines, breaking a paragraph for TeX.
 Check for mismatched braces or $s in paragraph being terminated.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]