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

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> 2014-11-13 Thomas Fitzsimmons <fitzsim@fitzsim.org>
* net/eudcb-ldap.el: Don't nag the user in case a default base is * net/eudcb-ldap.el: Don't nag the user in case a default base is
......
...@@ -856,80 +856,78 @@ see `eudc-inline-expansion-servers'" ...@@ -856,80 +856,78 @@ see `eudc-inline-expansion-servers'"
(> (length servers) eudc-max-servers-to-query)) (> (length servers) eudc-max-servers-to-query))
(setcdr (nthcdr (1- eudc-max-servers-to-query) servers) nil)) (setcdr (nthcdr (1- eudc-max-servers-to-query) servers) nil))
(condition-case signal (unwind-protect
(progn (condition-case signal
(setq response (progn
(catch 'found (setq response
;; Loop on the servers (catch 'found
(while servers ;; Loop on the servers
(eudc-set-server (eudc-caar servers) (eudc-cdar servers) t) (while servers
(eudc-set-server (eudc-caar servers) (eudc-cdar servers) t)
;; Determine which formats apply in the query-format list
(setq query-formats ;; Determine which formats apply in the query-format list
(or (setq query-formats
(eudc-extract-n-word-formats eudc-inline-query-format (or
(length query-words)) (eudc-extract-n-word-formats eudc-inline-query-format
(if (null eudc-protocol-has-default-query-attributes) (length query-words))
'(name)))) (if (null eudc-protocol-has-default-query-attributes)
'(name))))
;; Loop on query-formats
(while query-formats ;; Loop on query-formats
(setq response (while query-formats
(eudc-query (setq response
(eudc-format-query query-words (car query-formats)) (eudc-query
(eudc-translate-attribute-list (eudc-format-query query-words (car query-formats))
(cdr eudc-inline-expansion-format)))) (eudc-translate-attribute-list
(if response (cdr eudc-inline-expansion-format))))
(throw 'found response)) (if response
(setq query-formats (cdr query-formats))) (throw 'found response))
(setq servers (cdr servers))) (setq query-formats (cdr query-formats)))
;; No more servers to try... no match found (setq servers (cdr servers)))
nil)) ;; No more servers to try... no match found
nil))
(if (null response)
(error "No match") (if (null response)
(error "No match")
;; Process response through eudc-inline-expansion-format
(while response ;; Process response through eudc-inline-expansion-format
(setq response-string (apply 'format (while response
(car eudc-inline-expansion-format) (setq response-string (apply 'format
(mapcar (function (car eudc-inline-expansion-format)
(lambda (field) (mapcar (function
(or (cdr (assq field (car response))) (lambda (field)
""))) (or (cdr (assq field (car response)))
(eudc-translate-attribute-list "")))
(cdr eudc-inline-expansion-format))))) (eudc-translate-attribute-list
(if (> (length response-string) 0) (cdr eudc-inline-expansion-format)))))
(setq response-strings (if (> (length response-string) 0)
(cons response-string response-strings))) (setq response-strings
(setq response (cdr response))) (cons response-string response-strings)))
(setq response (cdr response)))
(if (or
(and replace (not eudc-expansion-overwrites-query)) (if (or
(and (not replace) eudc-expansion-overwrites-query)) (and replace (not eudc-expansion-overwrites-query))
(kill-ring-save beg end)) (and (not replace) eudc-expansion-overwrites-query))
(cond (kill-ring-save beg end))
((or (= (length response-strings) 1) (cond
(null eudc-multiple-match-handling-method) ((or (= (length response-strings) 1)
(eq eudc-multiple-match-handling-method 'first)) (null eudc-multiple-match-handling-method)
(delete-region beg end) (eq eudc-multiple-match-handling-method 'first))
(insert (car response-strings))) (delete-region beg end)
((eq eudc-multiple-match-handling-method 'select) (insert (car response-strings)))
(eudc-select response-strings beg end)) ((eq eudc-multiple-match-handling-method 'select)
((eq eudc-multiple-match-handling-method 'all) (eudc-select response-strings beg end))
(delete-region beg end) ((eq eudc-multiple-match-handling-method 'all)
(insert (mapconcat 'identity response-strings ", "))) (delete-region beg end)
((eq eudc-multiple-match-handling-method 'abort) (insert (mapconcat 'identity response-strings ", ")))
(error "There is more than one match for the query")))) ((eq eudc-multiple-match-handling-method 'abort)
(or (and (equal eudc-server eudc-former-server) (error "There is more than one match for the query")))))
(equal eudc-protocol eudc-former-protocol)) (error
(eudc-set-server eudc-former-server eudc-former-protocol t))) (signal (car signal) (cdr signal))))
(error (or (and (equal eudc-server eudc-former-server)
(or (and (equal eudc-server eudc-former-server) (equal eudc-protocol eudc-former-protocol))
(equal eudc-protocol eudc-former-protocol)) (eudc-set-server eudc-former-server eudc-former-protocol t)))))
(eudc-set-server eudc-former-server eudc-former-protocol t))
(signal (car signal) (cdr signal))))))
;;;###autoload ;;;###autoload
(defun eudc-query-form (&optional get-fields-from-server) (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