Commit 81d0909b authored by Thomas Fitzsimmons's avatar Thomas Fitzsimmons

Restore former eudc-expand-inline settings after a nonlocal exit

* net/eudc.el (eudc-expand-inline): Always restore former server
and protocol.
parent 78602273
2014-11-13 Thomas Fitzsimmons <fitzsim@fitzsim.org>
* net/eudc.el (eudc-expand-inline): Always restore former server
and protocol.
2014-11-13 Thomas Fitzsimmons <fitzsim@fitzsim.org>
* net/eudcb-ldap.el: Don't nag the user in case a default base is
......
......@@ -856,80 +856,78 @@ see `eudc-inline-expansion-servers'"
(> (length servers) eudc-max-servers-to-query))
(setcdr (nthcdr (1- eudc-max-servers-to-query) servers) nil))
(condition-case signal
(progn
(setq response
(catch 'found
;; Loop on the servers
(while servers
(eudc-set-server (eudc-caar servers) (eudc-cdar servers) t)
;; Determine which formats apply in the query-format list
(setq query-formats
(or
(eudc-extract-n-word-formats eudc-inline-query-format
(length query-words))
(if (null eudc-protocol-has-default-query-attributes)
'(name))))
;; Loop on query-formats
(while query-formats
(setq response
(eudc-query
(eudc-format-query query-words (car query-formats))
(eudc-translate-attribute-list
(cdr eudc-inline-expansion-format))))
(if response
(throw 'found response))
(setq query-formats (cdr query-formats)))
(setq servers (cdr servers)))
;; No more servers to try... no match found
nil))
(if (null response)
(error "No match")
;; Process response through eudc-inline-expansion-format
(while response
(setq response-string (apply 'format
(car eudc-inline-expansion-format)
(mapcar (function
(lambda (field)
(or (cdr (assq field (car response)))
"")))
(eudc-translate-attribute-list
(cdr eudc-inline-expansion-format)))))
(if (> (length response-string) 0)
(setq response-strings
(cons response-string response-strings)))
(setq response (cdr response)))
(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"))))
(or (and (equal eudc-server eudc-former-server)
(equal eudc-protocol eudc-former-protocol))
(eudc-set-server eudc-former-server eudc-former-protocol t)))
(error
(or (and (equal eudc-server eudc-former-server)
(equal eudc-protocol eudc-former-protocol))
(eudc-set-server eudc-former-server eudc-former-protocol t))
(signal (car signal) (cdr signal))))))
(unwind-protect
(condition-case signal
(progn
(setq response
(catch 'found
;; Loop on the servers
(while servers
(eudc-set-server (eudc-caar servers) (eudc-cdar servers) t)
;; Determine which formats apply in the query-format list
(setq query-formats
(or
(eudc-extract-n-word-formats eudc-inline-query-format
(length query-words))
(if (null eudc-protocol-has-default-query-attributes)
'(name))))
;; Loop on query-formats
(while query-formats
(setq response
(eudc-query
(eudc-format-query query-words (car query-formats))
(eudc-translate-attribute-list
(cdr eudc-inline-expansion-format))))
(if response
(throw 'found response))
(setq query-formats (cdr query-formats)))
(setq servers (cdr servers)))
;; No more servers to try... no match found
nil))
(if (null response)
(error "No match")
;; Process response through eudc-inline-expansion-format
(while response
(setq response-string (apply 'format
(car eudc-inline-expansion-format)
(mapcar (function
(lambda (field)
(or (cdr (assq field (car response)))
"")))
(eudc-translate-attribute-list
(cdr eudc-inline-expansion-format)))))
(if (> (length response-string) 0)
(setq response-strings
(cons response-string response-strings)))
(setq response (cdr response)))
(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")))))
(error
(signal (car signal) (cdr signal))))
(or (and (equal eudc-server eudc-former-server)
(equal eudc-protocol eudc-former-protocol))
(eudc-set-server eudc-former-server eudc-former-protocol t)))))
;;;###autoload
(defun eudc-query-form (&optional get-fields-from-server)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment