diff options
| author | Glenn Morris | 2013-05-23 23:53:54 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-05-23 23:53:54 -0700 |
| commit | 892f8ca3891684df1ea5927f93fec9e6e5cadb26 (patch) | |
| tree | 985dd1392c4e906a1e15ef99b4dbc5f93eb4eece | |
| parent | 3c29197330b409b01c6782947d386e1e249c3248 (diff) | |
| download | emacs-892f8ca3891684df1ea5927f93fec9e6e5cadb26.tar.gz emacs-892f8ca3891684df1ea5927f93fec9e6e5cadb26.zip | |
socks.el small cleanup
* lisp/net/socks.el (socks-split-string): Use this rather than split-string.
(socks-nslookup-host): Update for above change.
(dynamic-choice, s5-dynamic-choice-match)
(s5-dynamic-choice-match-inline, s5-widget-value-create):
Comment out unused code.
Comment out other unused code in a more standard manner, with ";"
rather than "'".
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/socks.el | 232 |
2 files changed, 124 insertions, 114 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 12fd433e431..0587ad3a618 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2013-05-24 Glenn Morris <rgm@gnu.org> | 1 | 2013-05-24 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * net/socks.el (socks-split-string): Use this rather than split-string. | ||
| 4 | (socks-nslookup-host): Update for above change. | ||
| 5 | (dynamic-choice, s5-dynamic-choice-match) | ||
| 6 | (s5-dynamic-choice-match-inline, s5-widget-value-create): | ||
| 7 | Comment out unused code. | ||
| 8 | |||
| 3 | * tooltip.el (tooltip-use-echo-area): Warn only on 'set. | 9 | * tooltip.el (tooltip-use-echo-area): Warn only on 'set. |
| 4 | * progmodes/gud.el (gud-gdb-completion-function): Move before use. | 10 | * progmodes/gud.el (gud-gdb-completion-function): Move before use. |
| 5 | (gud-tooltip-echo-area): Make obsolete. | 11 | (gud-tooltip-echo-area): Make obsolete. |
diff --git a/lisp/net/socks.el b/lisp/net/socks.el index 415397c4171..d6173e01ecd 100644 --- a/lisp/net/socks.el +++ b/lisp/net/socks.el | |||
| @@ -36,64 +36,67 @@ | |||
| 36 | (require 'wid-edit)) | 36 | (require 'wid-edit)) |
| 37 | (require 'custom) | 37 | (require 'custom) |
| 38 | 38 | ||
| 39 | ;; FIXME this is bad practice, and who is it for anyway, since Emacs | 39 | (eval-and-compile |
| 40 | ;; has split-string since at least 21.1. | 40 | (if (featurep 'emacs) |
| 41 | (if (not (fboundp 'split-string)) | 41 | (defalias 'socks-split-string 'split-string) ; since at least 21.1 |
| 42 | (defun split-string (string &optional pattern) | 42 | (if (fboundp 'split-string) |
| 43 | "Return a list of substrings of STRING which are separated by PATTERN. | 43 | (defalias 'socks-split-string 'split-string) |
| 44 | (defun socks-split-string (string &optional pattern) | ||
| 45 | "Return a list of substrings of STRING which are separated by PATTERN. | ||
| 44 | If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | 46 | If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." |
| 45 | (or pattern | 47 | (or pattern |
| 46 | (setq pattern "[ \f\t\n\r\v]+")) | 48 | (setq pattern "[ \f\t\n\r\v]+")) |
| 47 | (let (parts (start 0)) | 49 | (let (parts (start 0)) |
| 48 | (while (string-match pattern string start) | 50 | (while (string-match pattern string start) |
| 49 | (setq parts (cons (substring string start (match-beginning 0)) parts) | 51 | (setq parts (cons (substring string start |
| 50 | start (match-end 0))) | 52 | (match-beginning 0)) parts) |
| 51 | (nreverse (cons (substring string start) parts))))) | 53 | start (match-end 0))) |
| 54 | (nreverse (cons (substring string start) parts))))))) | ||
| 52 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 55 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 53 | ;;; Custom widgets | 56 | ;;; Custom widgets |
| 54 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 57 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 55 | (define-widget 'dynamic-choice 'menu-choice | 58 | ;;; (define-widget 'dynamic-choice 'menu-choice |
| 56 | "A pretty simple dynamic dropdown list" | 59 | ;;; "A pretty simple dynamic dropdown list" |
| 57 | :format "%[%t%]: %v" | 60 | ;;; :format "%[%t%]: %v" |
| 58 | :tag "Network" | 61 | ;;; :tag "Network" |
| 59 | :case-fold t | 62 | ;;; :case-fold t |
| 60 | :void '(item :format "invalid (%t)\n") | 63 | ;;; :void '(item :format "invalid (%t)\n") |
| 61 | :value-create 's5-widget-value-create | 64 | ;;; :value-create 's5-widget-value-create |
| 62 | :value-delete 'widget-children-value-delete | 65 | ;;; :value-delete 'widget-children-value-delete |
| 63 | :value-get 'widget-choice-value-get | 66 | ;;; :value-get 'widget-choice-value-get |
| 64 | :value-inline 'widget-choice-value-inline | 67 | ;;; :value-inline 'widget-choice-value-inline |
| 65 | :mouse-down-action 'widget-choice-mouse-down-action | 68 | ;;; :mouse-down-action 'widget-choice-mouse-down-action |
| 66 | :action 'widget-choice-action | 69 | ;;; :action 'widget-choice-action |
| 67 | :error "Make a choice" | 70 | ;;; :error "Make a choice" |
| 68 | :validate 'widget-choice-validate | 71 | ;;; :validate 'widget-choice-validate |
| 69 | :match 's5-dynamic-choice-match | 72 | ;;; :match 's5-dynamic-choice-match |
| 70 | :match-inline 's5-dynamic-choice-match-inline) | 73 | ;;; :match-inline 's5-dynamic-choice-match-inline) |
| 71 | 74 | ;;; | |
| 72 | (defun s5-dynamic-choice-match (widget value) | 75 | ;;; (defun s5-dynamic-choice-match (widget value) |
| 73 | (let ((choices (funcall (widget-get widget :choice-function))) | 76 | ;;; (let ((choices (funcall (widget-get widget :choice-function))) |
| 74 | current found) | 77 | ;;; current found) |
| 75 | (while (and choices (not found)) | 78 | ;;; (while (and choices (not found)) |
| 76 | (setq current (car choices) | 79 | ;;; (setq current (car choices) |
| 77 | choices (cdr choices) | 80 | ;;; choices (cdr choices) |
| 78 | found (widget-apply current :match value))) | 81 | ;;; found (widget-apply current :match value))) |
| 79 | found)) | 82 | ;;; found)) |
| 80 | 83 | ;;; | |
| 81 | (defun s5-dynamic-choice-match-inline (widget value) | 84 | ;;; (defun s5-dynamic-choice-match-inline (widget value) |
| 82 | (let ((choices (funcall (widget-get widget :choice-function))) | 85 | ;;; (let ((choices (funcall (widget-get widget :choice-function))) |
| 83 | current found) | 86 | ;;; current found) |
| 84 | (while (and choices (not found)) | 87 | ;;; (while (and choices (not found)) |
| 85 | (setq current (car choices) | 88 | ;;; (setq current (car choices) |
| 86 | choices (cdr choices) | 89 | ;;; choices (cdr choices) |
| 87 | found (widget-match-inline current value))) | 90 | ;;; found (widget-match-inline current value))) |
| 88 | found)) | 91 | ;;; found)) |
| 89 | 92 | ;;; | |
| 90 | (defun s5-widget-value-create (widget) | 93 | ;;; (defun s5-widget-value-create (widget) |
| 91 | (let ((choices (funcall (widget-get widget :choice-function))) | 94 | ;;; (let ((choices (funcall (widget-get widget :choice-function))) |
| 92 | (value (widget-get widget :value))) | 95 | ;;; (value (widget-get widget :value))) |
| 93 | (if (not value) | 96 | ;;; (if (not value) |
| 94 | (widget-put widget :value (widget-value (car choices)))) | 97 | ;;; (widget-put widget :value (widget-value (car choices)))) |
| 95 | (widget-put widget :args choices) | 98 | ;;; (widget-put widget :args choices) |
| 96 | (widget-choice-value-create widget))) | 99 | ;;; (widget-choice-value-create widget))) |
| 97 | 100 | ||
| 98 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 101 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 99 | ;;; Customization support | 102 | ;;; Customization support |
| @@ -104,65 +107,65 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | |||
| 104 | :prefix "socks-" | 107 | :prefix "socks-" |
| 105 | :group 'processes) | 108 | :group 'processes) |
| 106 | 109 | ||
| 107 | '(defcustom socks-server-aliases nil | 110 | ;;; (defcustom socks-server-aliases nil |
| 108 | "A list of server aliases for use in access control and filtering rules." | 111 | ;;; "A list of server aliases for use in access control and filtering rules." |
| 109 | :group 'socks | 112 | ;;; :group 'socks |
| 110 | :type '(repeat (list :format "%v" | 113 | ;;; :type '(repeat (list :format "%v" |
| 111 | :value ("" "" 1080 5) | 114 | ;;; :value ("" "" 1080 5) |
| 112 | (string :tag "Alias") | 115 | ;;; (string :tag "Alias") |
| 113 | (string :tag "Hostname/IP Address") | 116 | ;;; (string :tag "Hostname/IP Address") |
| 114 | (integer :tag "Port #") | 117 | ;;; (integer :tag "Port #") |
| 115 | (choice :tag "SOCKS Version" | 118 | ;;; (choice :tag "SOCKS Version" |
| 116 | (integer :tag "SOCKS v4" :value 4) | 119 | ;;; (integer :tag "SOCKS v4" :value 4) |
| 117 | (integer :tag "SOCKS v5" :value 5))))) | 120 | ;;; (integer :tag "SOCKS v5" :value 5))))) |
| 118 | 121 | ;;; | |
| 119 | '(defcustom socks-network-aliases | 122 | ;;; (defcustom socks-network-aliases |
| 120 | '(("Anywhere" (netmask "0.0.0.0" "0.0.0.0"))) | 123 | ;;; '(("Anywhere" (netmask "0.0.0.0" "0.0.0.0"))) |
| 121 | "A list of network aliases for use in subsequent rules." | 124 | ;;; "A list of network aliases for use in subsequent rules." |
| 122 | :group 'socks | 125 | ;;; :group 'socks |
| 123 | :type '(repeat (list :format "%v" | 126 | ;;; :type '(repeat (list :format "%v" |
| 124 | :value (netmask "" "255.255.255.0") | 127 | ;;; :value (netmask "" "255.255.255.0") |
| 125 | (string :tag "Alias") | 128 | ;;; (string :tag "Alias") |
| 126 | (radio-button-choice | 129 | ;;; (radio-button-choice |
| 127 | :format "%v" | 130 | ;;; :format "%v" |
| 128 | (list :tag "IP address range" | 131 | ;;; (list :tag "IP address range" |
| 129 | (const :format "" :value range) | 132 | ;;; (const :format "" :value range) |
| 130 | (string :tag "From") | 133 | ;;; (string :tag "From") |
| 131 | (string :tag "To")) | 134 | ;;; (string :tag "To")) |
| 132 | (list :tag "IP address/netmask" | 135 | ;;; (list :tag "IP address/netmask" |
| 133 | (const :format "" :value netmask) | 136 | ;;; (const :format "" :value netmask) |
| 134 | (string :tag "IP Address") | 137 | ;;; (string :tag "IP Address") |
| 135 | (string :tag "Netmask")) | 138 | ;;; (string :tag "Netmask")) |
| 136 | (list :tag "Domain Name" | 139 | ;;; (list :tag "Domain Name" |
| 137 | (const :format "" :value domain) | 140 | ;;; (const :format "" :value domain) |
| 138 | (string :tag "Domain name")) | 141 | ;;; (string :tag "Domain name")) |
| 139 | (list :tag "Unique hostname/IP address" | 142 | ;;; (list :tag "Unique hostname/IP address" |
| 140 | (const :format "" :value exact) | 143 | ;;; (const :format "" :value exact) |
| 141 | (string :tag "Hostname/IP Address")))))) | 144 | ;;; (string :tag "Hostname/IP Address")))))) |
| 142 | 145 | ;;; | |
| 143 | '(defun s5-servers-filter () | 146 | ;;; (defun s5-servers-filter () |
| 144 | (if socks-server-aliases | 147 | ;;; (if socks-server-aliases |
| 145 | (mapcar (lambda (x) (list 'const :tag (car x) :value (car x))) s5-server-aliases) | 148 | ;;; (mapcar (lambda (x) (list 'const :tag (car x) :value (car x))) s5-server-aliases) |
| 146 | '((const :tag "No aliases defined" :value nil)))) | 149 | ;;; '((const :tag "No aliases defined" :value nil)))) |
| 147 | 150 | ;;; | |
| 148 | '(defun s5-network-aliases-filter () | 151 | ;;; (defun s5-network-aliases-filter () |
| 149 | (mapcar (lambda (x) (list 'const :tag (car x) :value (car x))) | 152 | ;;; (mapcar (lambda (x) (list 'const :tag (car x) :value (car x))) |
| 150 | socks-network-aliases)) | 153 | ;;; socks-network-aliases)) |
| 151 | 154 | ;;; | |
| 152 | '(defcustom socks-redirection-rules | 155 | ;;; (defcustom socks-redirection-rules |
| 153 | nil | 156 | ;;; nil |
| 154 | "A list of redirection rules." | 157 | ;;; "A list of redirection rules." |
| 155 | :group 'socks | 158 | ;;; :group 'socks |
| 156 | :type '(repeat (list :format "%v" | 159 | ;;; :type '(repeat (list :format "%v" |
| 157 | :value ("Anywhere" nil) | 160 | ;;; :value ("Anywhere" nil) |
| 158 | (dynamic-choice :choice-function s5-network-aliases-filter | 161 | ;;; (dynamic-choice :choice-function s5-network-aliases-filter |
| 159 | :tag "Destination network") | 162 | ;;; :tag "Destination network") |
| 160 | (radio-button-choice | 163 | ;;; (radio-button-choice |
| 161 | :tag "Connection type" | 164 | ;;; :tag "Connection type" |
| 162 | (const :tag "Direct connection" :value nil) | 165 | ;;; (const :tag "Direct connection" :value nil) |
| 163 | (dynamic-choice :format "%t: %[%v%]" | 166 | ;;; (dynamic-choice :format "%t: %[%v%]" |
| 164 | :choice-function s5-servers-filter | 167 | ;;; :choice-function s5-servers-filter |
| 165 | :tag "Proxy chain via"))))) | 168 | ;;; :tag "Proxy chain via"))))) |
| 166 | 169 | ||
| 167 | (defcustom socks-server | 170 | (defcustom socks-server |
| 168 | (list "Default server" "socks" 1080 5) | 171 | (list "Default server" "socks" 1080 5) |
| @@ -648,7 +651,8 @@ version.") | |||
| 648 | (progn | 651 | (progn |
| 649 | (setq res (buffer-substring (match-beginning 2) | 652 | (setq res (buffer-substring (match-beginning 2) |
| 650 | (match-end 2)) | 653 | (match-end 2)) |
| 651 | res (mapcar 'string-to-number (split-string res "\\."))))) | 654 | res (mapcar 'string-to-number |
| 655 | (socks-split-string res "\\."))))) | ||
| 652 | (kill-buffer (current-buffer))) | 656 | (kill-buffer (current-buffer))) |
| 653 | res) | 657 | res) |
| 654 | host)) | 658 | host)) |