aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-05-07 00:05:21 -0700
committerGlenn Morris2013-05-07 00:05:21 -0700
commit7cc8ae065c3840d74921a673f1c7e480b092e295 (patch)
treeea102f72dbb65d14e248bb982f8c8ff6f6c687fb
parente0c9d5650500f980701f1e0288db73ee32cbe7d0 (diff)
downloademacs-7cc8ae065c3840d74921a673f1c7e480b092e295.tar.gz
emacs-7cc8ae065c3840d74921a673f1c7e480b092e295.zip
* lisp/progmodes/f90.el (f90-smart-end-names): New option.
(f90-smart-end): Doc fix. (f90-end-block-optional-name): New constant. (f90-block-match): Respect f90-smart-end-names. * etc/NEWS: Mention this.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/f90.el43
3 files changed, 47 insertions, 6 deletions
diff --git a/etc/NEWS b/etc/NEWS
index f278317b08d..4261f239610 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -198,6 +198,9 @@ auto-saves of the desktop.
198If set to a number, this can be used to avoid accidentally paste large 198If set to a number, this can be used to avoid accidentally paste large
199amounts of data into the ERC input. 199amounts of data into the ERC input.
200 200
201---
202** New F90 mode option `f90-smart-end-names'.
203
201** Icomplete is a bit more like IDO. 204** Icomplete is a bit more like IDO.
202*** key bindings to navigate through and select the completions. 205*** key bindings to navigate through and select the completions.
203*** The icomplete-separator is customizable, and its default has changed. 206*** The icomplete-separator is customizable, and its default has changed.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a6eed51b9b5..2d4a6385362 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-05-07 Glenn Morris <rgm@gnu.org>
2
3 * progmodes/f90.el (f90-smart-end-names): New option.
4 (f90-smart-end): Doc fix.
5 (f90-end-block-optional-name): New constant.
6 (f90-block-match): Respect f90-smart-end-names.
7
12013-05-07 Stefan Monnier <monnier@iro.umontreal.ca> 82013-05-07 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * progmodes/octave.el (octave-smie-forward-token): Be more careful 10 * progmodes/octave.el (octave-smie-forward-token): Be more careful
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index dba1d6a2f9b..924f9d8ac3d 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -247,15 +247,36 @@
247 247
248(defcustom f90-smart-end 'blink 248(defcustom f90-smart-end 'blink
249 "Qualification of END statements according to the matching block start. 249 "Qualification of END statements according to the matching block start.
250For example, the END that closes an IF block is changed to END 250For example, change the END that closes an IF block to END IF.
251IF. If the block has a label, this is added as well. Allowed 251If the block has a label, add it as well (unless `f90-smart-end-names'
252values are 'blink, 'no-blink, and nil. If nil, nothing is done. 252says not to). Allowed values are 'blink, 'no-blink, and nil. If nil,
253The other two settings have the same effect, but 'blink 253nothing is done. The other two settings have the same effect, but 'blink
254additionally blinks the cursor to the start of the block." 254additionally blinks the cursor to the start of the block."
255 :type '(choice (const blink) (const no-blink) (const nil)) 255 :type '(choice (const blink) (const no-blink) (const nil))
256 :safe (lambda (value) (memq value '(blink no-blink nil))) 256 :safe (lambda (value) (memq value '(blink no-blink nil)))
257 :group 'f90) 257 :group 'f90)
258 258
259;; Optional: program, module, type, function, subroutine
260;; Not optional: block data?, forall, if, select case/type, associate, do,
261;; where, interface, critical
262;; No labels: enum
263(defcustom f90-smart-end-names t
264 "Whether completion of END statements should insert optional block names.
265For example, when closing a \"PROGRAM PROGNAME\" block, \"PROGNAME\" is
266optional in the \"END PROGRAM\" statement. The same is true for modules,
267functions, subroutines, and types. Some people prefer to omit the name
268from the END statement, since it makes it easier to change the name.
269
270This does not apply to named DO, IF, etc. blocks. If such blocks
271start with a label, they must end with one.
272
273If an end statement has a name that does not match the start, it is always
274corrected, regardless of the value of this variable."
275 :type 'boolean
276 :safe 'booleanp
277 :group 'f90
278 :version "24.4")
279
259(defcustom f90-break-delimiters "[-+\\*/><=,% \t]" 280(defcustom f90-break-delimiters "[-+\\*/><=,% \t]"
260 "Regexp matching delimiter characters at which lines may be broken. 281 "Regexp matching delimiter characters at which lines may be broken.
261There are some common two-character tokens where one or more of 282There are some common two-character tokens where one or more of
@@ -2108,12 +2129,19 @@ Like `join-line', but handles F90 syntax."
2108 (zmacs-deactivate-region) 2129 (zmacs-deactivate-region)
2109 (deactivate-mark)))) 2130 (deactivate-mark))))
2110 2131
2132(defconst f90-end-block-optional-name
2133 '("program" "module" "subroutine" "function" "type")
2134 "Block types where including the name in the end statement is optional.")
2135
2111(defun f90-block-match (beg-block beg-name end-block end-name) 2136(defun f90-block-match (beg-block beg-name end-block end-name)
2112 "Match end-struct with beg-struct and complete end-block if possible. 2137 "Match end-struct with beg-struct and complete end-block if possible.
2113BEG-BLOCK is the type of block as indicated at the start (e.g., do). 2138BEG-BLOCK is the type of block as indicated at the start (e.g., do).
2114BEG-NAME is the block start name (may be nil). 2139BEG-NAME is the block start name (may be nil).
2115END-BLOCK is the type of block as indicated at the end (may be nil). 2140END-BLOCK is the type of block as indicated at the end (may be nil).
2116END-NAME is the block end name (may be nil). 2141END-NAME is the block end name (may be nil).
2142If the block type matches `f90-end-block-optional-name', do not add
2143an end name if `f90-smart-end-names' is nil, but always update an
2144incorrect end name if there already was one.
2117Leave point at the end of line." 2145Leave point at the end of line."
2118 ;; Hack to deal with the case when this is called from 2146 ;; Hack to deal with the case when this is called from
2119 ;; f90-indent-region on a program block without an explicit PROGRAM 2147 ;; f90-indent-region on a program block without an explicit PROGRAM
@@ -2133,8 +2161,11 @@ Leave point at the end of line."
2133 (if (f90-equal-symbols beg-name end-name) 2161 (if (f90-equal-symbols beg-name end-name)
2134 (and end-name (search-forward end-name)) 2162 (and end-name (search-forward end-name))
2135 (cond ((and beg-name (not end-name)) 2163 (cond ((and beg-name (not end-name))
2136 (message "Inserting %s." beg-name) 2164 (unless (and (not f90-smart-end-names)
2137 (insert (concat " " beg-name))) 2165 (member-ignore-case beg-block
2166 f90-end-block-optional-name))
2167 (message "Inserting %s." beg-name)
2168 (insert (concat " " beg-name))))
2138 ((and beg-name end-name) 2169 ((and beg-name end-name)
2139 (message "Replacing %s with %s." end-name beg-name) 2170 (message "Replacing %s with %s." end-name beg-name)
2140 (search-forward end-name) 2171 (search-forward end-name)