Function: verilog-complete-word

verilog-complete-word is an interactive and byte-compiled function defined in verilog-mode.el.gz.

Signature

(verilog-complete-word)

Documentation

Complete word at current point.

(See also verilog-toggle-completions, verilog-type-keywords,
and verilog-separator-keywords.)

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/verilog-mode.el.gz
(defun verilog-complete-word ()
  "Complete word at current point.
\(See also `verilog-toggle-completions', `verilog-type-keywords',
and `verilog-separator-keywords'.)"
  ;; NOTE: This is just a fallback for Emacs versions lacking
  ;; `completion-at-point'.
  (interactive)
  (let* ((comp-info (verilog-completion-at-point))
         (b (nth 0 comp-info))
	 (e (nth 1 comp-info))
	 (verilog-str (buffer-substring b e))
	 (allcomp (nth 2 comp-info))
	 (match (if verilog-toggle-completions
                   "" (try-completion verilog-str allcomp))))
    ;; Delete old string
    (delete-region b e)

    ;; Toggle-completions inserts whole labels
    (if verilog-toggle-completions
	(progn
	  ;; Update entry number in list
	  (setq verilog-last-completions allcomp
		verilog-last-word-numb
		(if (>= verilog-last-word-numb (1- (length allcomp)))
		    0
		  (1+ verilog-last-word-numb)))
	  (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb))
	  ;; Display next match or same string if no match was found
	  (if (not (null allcomp))
	      (insert "" verilog-last-word-shown)
	    (insert "" verilog-str)
	    (message "(No match)")))
      ;; The other form of completion does not necessarily do that.

      ;; Insert match if found, or the original string if no match
      (if (or (null match) (equal match 't))
	  (progn (insert "" verilog-str)
		 (message "(No match)"))
	(insert "" match))
      ;; Give message about current status of completion
      (cond ((equal match 't)
	     (if (not (null (cdr allcomp)))
		 (message "(Complete but not unique)")
	       (message "(Sole completion)")))
	    ;; Display buffer if the current completion didn't help
	    ;; on completing the label.
	    ((and (not (null (cdr allcomp))) (= (length verilog-str)
						(length match)))
	     (with-output-to-temp-buffer "*Completions*"
	       (display-completion-list allcomp))
	     ;; Wait for a key press. Then delete *Completion*  window
	     (momentary-string-display "" (point))
	     (verilog-quit-window nil (get-buffer-window "*Completions*"))
	     )))))