Function: eudc-expand-inline

eudc-expand-inline is an autoloaded, interactive and byte-compiled function defined in eudc.el.gz.

Signature

(eudc-expand-inline &optional REPLACE)

Documentation

Query the directory server, and expand the query string before point.

The query string consists of the buffer substring from the point back to the preceding comma, colon or beginning of line. The variable eudc-inline-query-format controls how to associate the individual inline query words with directory attribute names. After querying the server for the given string, the expansion specified by eudc-inline-expansion-format is inserted in the buffer at point. If REPLACE is non-nil, then this expansion replaces the name in the buffer. eudc-expansion-overwrites-query being non-nil inverts the meaning of REPLACE. Multiple servers can be tried with the same query until one finds a match, see eudc-inline-expansion-servers.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/net/eudc.el.gz
;;;###autoload
(defun eudc-expand-inline (&optional replace)
  "Query the directory server, and expand the query string before point.
The query string consists of the buffer substring from the point back to
the preceding comma, colon or beginning of line.
The variable `eudc-inline-query-format' controls how to associate the
individual inline query words with directory attribute names.
After querying the server for the given string, the expansion specified by
`eudc-inline-expansion-format' is inserted in the buffer at point.
If REPLACE is non-nil, then this expansion replaces the name in the buffer.
`eudc-expansion-overwrites-query' being non-nil inverts the meaning of REPLACE.
Multiple servers can be tried with the same query until one finds a match,
see `eudc-inline-expansion-servers'."
  (interactive)
  (let* ((end (point))
	 (beg (save-excursion
		(if (re-search-backward "\\([:,]\\|^\\)[ \t]*"
					(point-at-bol) 'move)
		    (goto-char (match-end 0)))
		(point)))
	 (query-words (split-string (buffer-substring-no-properties beg end)
				    "[ \t]+"))
	 (response-strings (eudc-query-with-words query-words)))
    (if (null response-strings)
        (error "No match")

      (if (or
	   (and replace (not eudc-expansion-overwrites-query))
	   (and (not replace) eudc-expansion-overwrites-query))
	  (kill-ring-save beg end))
      (cond
       ((or (= (length response-strings) 1)
	    (null eudc-multiple-match-handling-method)
	    (eq eudc-multiple-match-handling-method 'first))
	(delete-region beg end)
	(insert (car response-strings)))
       ((eq eudc-multiple-match-handling-method 'select)
	(eudc-select response-strings beg end))
       ((eq eudc-multiple-match-handling-method 'all)
	(delete-region beg end)
	(insert (mapconcat #'identity response-strings ", ")))
       ((eq eudc-multiple-match-handling-method 'abort)
	(error "There is more than one match for the query"))))))