Function: idlwave-expand-equal

idlwave-expand-equal is a byte-compiled function defined in idlwave.el.gz.

Signature

(idlwave-expand-equal &optional BEFORE AFTER IS-ACTION)

Documentation

Pad = with spaces.

Two cases: Assignment statement, and keyword assignment. Which case is determined using idlwave-start-of-substatement and idlwave-statement-type. The equal sign will be surrounded by BEFORE and AFTER blanks. If idlwave-pad-keyword is t then keyword assignment is treated just like assignment statements. When nil, spaces are removed for keyword assignment. Any other value keeps the current space around the =. Limits in for loops are treated as keyword assignment.

Starting with IDL 6.0, a number of op= assignments are available. Since ambiguities of the form:

r and= b rand= b

can occur, alphanumeric operator assignment will never be pre-padded, only post-padded. You must use a space before these to disambiguate
(not just for padding, but for proper parsing by IDL too!). Other
operators, such as ##=, ^=, etc., will be pre-padded.

IS-ACTION is ignored.

See idlwave-surround.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/idlwave.el.gz
(defun idlwave-expand-equal (&optional before after _is-action)
  "Pad `=' with spaces.
Two cases: Assignment statement, and keyword assignment.
Which case is determined using `idlwave-start-of-substatement' and
`idlwave-statement-type'.  The equal sign will be surrounded by BEFORE
and AFTER blanks.  If `idlwave-pad-keyword' is t then keyword assignment
is treated just like assignment statements.  When nil, spaces are
removed for keyword assignment.  Any other value keeps the current space
around the `='.  Limits in for loops are treated as keyword assignment.

Starting with IDL 6.0, a number of op= assignments are available.
Since ambiguities of the form:

r and= b
rand= b

can occur, alphanumeric operator assignment will never be pre-padded,
only post-padded.  You must use a space before these to disambiguate
\(not just for padding, but for proper parsing by IDL too!).  Other
operators, such as ##=, ^=, etc., will be pre-padded.

IS-ACTION is ignored.

See `idlwave-surround'."
  (if idlwave-surround-by-blank
      (let
	  ((non-an-ops "\\(##\\|\\*\\|\\+\\|-\\|/\\|<\\|>\\|\\^\\)\\=")
	   (an-ops
	    "\\s-\\(AND\\|EQ\\|GE\\|GT\\|LE\\|LT\\|MOD\\|NE\\|OR\\|XOR\\)\\=")
	   (len 1))

	(save-excursion
	  (let ((case-fold-search t))
	    (backward-char)
	    (if (or
		 (re-search-backward non-an-ops nil t)
		 ;; Why doesn't ##? work for both?
		 (re-search-backward "\\(#\\)\\=" nil t))
		(setq len (1+ (length (match-string 1))))
	      (when (re-search-backward an-ops nil t)
		;(setq begin nil) ; won't modify begin
		(setq len (1+ (length (match-string 1))))))))

	(if (eq t idlwave-pad-keyword)
	    ;; Everything gets padded equally
	    (idlwave-surround before after len)
	  ;; Treating keywords/for variables specially...
	  (let ((st (save-excursion   ; To catch "for" variables
		      (idlwave-start-of-substatement t)
		      (idlwave-statement-type)))
		(what (save-excursion ; To catch keywords
			(skip-chars-backward "= \t")
			(nth 2 (idlwave-where)))))
	    (cond ((or (memq what '(function-keyword procedure-keyword))
		       (memq (caar st) '(for pdef)))
		   (cond
		    ((null idlwave-pad-keyword)
		     (idlwave-surround 0 0)
		     ) ; remove space
		    (t))) ; leave any spaces alone
		  (t (idlwave-surround before after len))))))))