[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 6792a81 083/184: Simple indentation fix for new bl
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 6792a81 083/184: Simple indentation fix for new block-structured do and if |
Date: |
Sun, 29 Aug 2021 11:03:20 -0400 (EDT) |
branch: elpa/gnuplot
commit 6792a81168f635b56d9c837e3597f12ae012b4c8
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Simple indentation fix for new block-structured do and if
---
gnuplot.el | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/gnuplot.el b/gnuplot.el
index 73ba8d8..413fc0d 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -641,6 +641,14 @@ to the empty string."
:type '(radio (const :tag "double quote" "\"")
(const :tag "single quote" "\'")
(const :tag "none" "" )))
+(defcustom gnuplot-basic-offset 4
+ "Number of columns to indent lines inside a do- or if-else-block.
+
+This applies only to new-style do- and if-statements using
+braces. Commands continued over a linebreak using a backslash are
+always indented to line up with the second word on the line
+beginning the continued command.")
+
;; (defcustom gnuplot-gnuplot-version nil
;; "*Force gnuplot-mode to behave for this version of gnuplot."
;; :group 'gnuplot
@@ -762,6 +770,7 @@ symbol `complete' in gnuplot-mode buffers."
(define-key gnuplot-mode-map "\C-i" 'indent-for-tab-command)
(define-key gnuplot-mode-map "\C-m" 'newline-and-indent)
(define-key gnuplot-mode-map "\C-c\M-i" 'gnuplot-inline-image-mode)
+ (define-key gnuplot-mode-map (kbd "}") 'gnuplot-electric-insert)
(let ((completion-function
(if (fboundp 'completion-at-point)
@@ -2548,24 +2557,32 @@ Add additional indentation for continuation lines."
(re-search-forward "\\S-+\\s-+" (point-at-eol) 'end-at-limit)
(setq indent (- (point) (point-at-bol))))
- ;; Not a continuation line; go back to the first non-blank,
- ;; non-continuation line and indent to the same level
- (beginning-of-line 0)
- (while (and (not (bobp))
- (or (gnuplot-continuation-line-p)
- (looking-at "\\s-*$")))
- (beginning-of-line 0))
- (if (bobp)
- (setq indent 0)
- (setq indent (current-indentation))))))
-
+ ;; Not a continuation line; indent according to block
+ ;; nesting depth
+ (save-excursion
+ (condition-case nil
+ (progn
+ (beginning-of-line)
+ (skip-syntax-forward "-)" (point-at-eol))
+ (backward-up-list)
+ (gnuplot-beginning-of-continuation)
+ (setq indent (+ gnuplot-basic-offset (current-indentation))))
+ (scan-error
+ (setq indent 0)))))))
+
;; Set indentation
(save-excursion
(indent-line-to indent))
+ ;; Move point after indentation when at beginning of line
(let ((point-at-indent (+ (point-at-bol) indent)))
(when (< (point) point-at-indent) (goto-char point-at-indent)))))
+(defun gnuplot-electric-insert (arg)
+ (interactive "*p")
+ (self-insert-command arg)
+ (gnuplot-indent-line))
+
;;
;; Functions for finding the start and end of continuation blocks
;;
- [nongnu] elpa/gnuplot 5030976 051/184: Alter header to conform to package.el specifications, (continued)
- [nongnu] elpa/gnuplot 5030976 051/184: Alter header to conform to package.el specifications, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e02534c 066/184: Add menu items for context-sensitive and inline-image modes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a70749e 054/184: Fix "replot" command in grammar., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0ff395e 071/184: Compatibility hacks for pre-23 emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c3e13f0 076/184: change version number to 0.7beta to avoid any confusion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 319a176 072/184: clean up tests a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e9447f0 048/184: More consistent keys between gnuplot.el and gnuplot-context.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ea83e14 081/184: cleanup parsing tests some more, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot b618811 069/184: Silence some compiler warnings about obsolete font-lock faces, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c520e94 075/184: Remove a redundant check for gnuplot-keywords-pending, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6792a81 083/184: Simple indentation fix for new block-structured do and if,
ELPA Syncer <=
- [nongnu] elpa/gnuplot 7e33d0d 087/184: three fixes: indentation, require cl macros, fix defc, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 9dd0e15 096/184: Avoid having text syntax-property changes mark buffer as modified, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c52bb6c 089/184: grammar fixes for new-style if statement and blocks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e457287 099/184: Add aclocal.m4 into repository, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f5c4437 100/184: Reduce autotools dependency to version 2.61, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e1ee092 097/184: Merge branch 'devel' containing 0.7 release candidate., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d9ed05b 105/184: remove broken link from readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot aefd4f6 106/184: Cleanup version numbers and copyright dates, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 4858b0d 110/184: Set syntax table in comint buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c2aedf8 111/184: Add ERT tests to check comment and string syntax., ELPA Syncer, 2021/08/29