Skip to content

Instantly share code, notes, and snippets.

@linktohack
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linktohack/9024f49eb1727a9f548b to your computer and use it in GitHub Desktop.
Save linktohack/9024f49eb1727a9f548b to your computer and use it in GitHub Desktop.
fortran insert continuation symbol (ampersand &) that match both fixed and free format.
(defun fortran-insert-f90-continuation ()
"Insert continuation symbol (ampersand &) that match both fixed and
free format.
If the inserted ampersand is the first non-blank character, just
insert it, otherwise, insert it at column 72 (zero-based index)
and insert another ampersand at column 6 on next line.
Also indent next line if `electric-indent-mode` is on."
(interactive)
(let ((beg (line-beginning-position))
(end (point)))
(setq s (buffer-substring-no-properties beg end))
(if (string-match "^[ \t]*$" s)
(insert "&")
(progn
(insert "\n &")
(previous-line)
(move-to-column 72 t)
(insert "&")
(next-line)))
(when electric-indent-mode
(indent-for-tab-command))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment