Mercurial > emacs
annotate lisp/url/url-methods.el @ 111870:b47e85affa59
Derive from prog-mode, use derived-mode-p, and fix up various
minor style issues in lisp/progmodes.
* lisp/progmodes/vhdl-mode.el (vhdl-write-file-hooks-init)
(vhdl-hs-minor-mode, vhdl-ps-print-init): Fix make-local-variable ->
make-local-hook.
* lisp/progmodes/sh-script.el (sh-require-final-newline): Remove.
(sh-set-shell): Don't set require-final-newline since it's already done
by prog-mode.
* lisp/progmodes/modula2.el (m2-mode): Don't make m2-end-comment-column
since we never set it.
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
Use read-string and standard prompt.
* lisp/progmodes/dcl-mode.el (dcl-mode-map): Move init into declaration.
* lisp/progmodes/meta-mode.el (meta-mode-abbrev-table): Merge init and decl.
(meta-common-mode-syntax-table): Rename from meta-mode-syntax-table.
(meta-common-mode-map): Rename from meta-mode-map.
Remove C-m binding, which is a user preference, not mode specific.
(meta-common-mode): New major mode; replace meta-common-initialization.
* lisp/progmodes/js.el (js-mode): Call syntax-propertize rather than messing
around with font-lock.
* lisp/progmodes/etags.el (select-tags-table-mode):
Derive from special-mode.
* lisp/progmodes/octave-mod.el (octave-mode):
* lisp/progmodes/gdb-mi.el (gdb-inferior-io-mode, gdb-threads-mode)
(gdb-memory-mode, gdb-disassembly-mode, gdb-breakpoints-mode)
(gdb-frames-mode, gdb-locals-mode, gdb-registers-mode):
Let define-derived-mode do its job.
* lisp/progmodes/cpp.el (cpp-edit-mode-map):
Move initialization into declaration.
(cpp-edit-mode): Use define-derived-mode.
(cpp-edit-load): Use derived-mode-p.
* lisp/progmodes/mixal-mode.el (mixal-mode):
* lisp/progmodes/f90.el (f90-mode):
* lisp/progmodes/cfengine.el (cfengine-mode): Don't bother setting
require-final-newline since prog-mode does it already.
* lisp/progmodes/cc-cmds.el (c-update-modeline): Use match-string.
* lisp/progmodes/asm-mode.el (asm-mode-map): Fix menu setup.
* lisp/progmodes/antlr-mode.el: Require cc-mode upfront.
(antlr-mode-syntax-table, antlr-action-syntax-table): Initialize in
the declaration.
(antlr-directory-dependencies, antlr-show-makefile-rules):
Use derived-mode-p.
(antlr-language-option): Don't assume point-min==1.
(antlr-mode): Use define-derived-mode.
* lisp/progmodes/ada-mode.el: Use derived-mode-p.
(ada-mode): Use define-derived-mode.
Use hack-local-variables-hook.
* lisp/progmodes/vhdl-mode.el (vhdl-mode):
* lisp/progmodes/verilog-mode.el (verilog-mode):
* lisp/progmodes/vera-mode.el (vera-mode):
* lisp/progmodes/sql.el (sql-mode):
* lisp/progmodes/scheme.el (scheme-mode):
* lisp/progmodes/perl-mode.el (perl-mode):
* lisp/progmodes/octave-inf.el (inferior-octave-mode):
* lisp/progmodes/autoconf.el (autoconf-mode):
* lisp/progmodes/m4-mode.el (m4-mode):
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode):
* lisp/progmodes/idlwave.el (idlwave-mode):
* lisp/progmodes/icon.el (icon-mode):
* lisp/progmodes/idlw-help.el (idlwave-help-mode):
* lisp/progmodes/dcl-mode.el (dcl-mode):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode):
* lisp/progmodes/ebrowse.el (ebrowse-tree-mode, ebrowse-electric-list-mode)
(ebrowse-member-mode, ebrowse-electric-position-mode):
Use define-derived-mode.
* lisp/progmodes/xscheme.el (xscheme-start)
(local-set-scheme-interaction-buffer, scheme-interaction-mode):
* lisp/progmodes/which-func.el (which-function):
* lisp/progmodes/vhdl-mode.el (vhdl-set-style):
* lisp/progmodes/verilog-mode.el (verilog-set-compile-command)
(verilog-modify-compile-command, verilog-error-regexp-add-xemacs)
(verilog-set-define, verilog-auto-reeval-locals):
* lisp/progmodes/sql.el (sql-product-font-lock, sql-interactive-mode):
* lisp/progmodes/simula.el (simula-mode):
* lisp/progmodes/scheme.el (scheme-mode-variables, dsssl-mode):
* lisp/progmodes/python.el (python-check, python-mode):
* lisp/progmodes/prolog.el (prolog-mode-variables):
* lisp/progmodes/gud.el (gud-tooltip-activate-mouse-motions):
* lisp/progmodes/ebrowse.el (ebrowse-view-file-other-frame):
* lisp/progmodes/delphi.el (delphi-mode):
* lisp/progmodes/cc-styles.el (c-setup-paragraph-variables):
* lisp/progmodes/cc-mode.el (c-basic-common-init, c-common-init)
(c-font-lock-init): Move make-local-variable to their setq.
* lisp/progmodes/xscheme.el (exit-scheme-interaction-mode)
(xscheme-enter-interaction-mode, xscheme-enter-debugger-mode)
(xscheme-debugger-mode-p, xscheme-send-string-1):
* lisp/progmodes/tcl.el (inferior-tcl-proc, tcl-current-word)
(tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/ps-mode.el (ps-run-running):
* lisp/progmodes/gdb-mi.el (gud-watch, gdb-mouse-set-clear-breakpoint):
* lisp/progmodes/js.el (js--get-all-known-symbols):
* lisp/progmodes/inf-lisp.el (inferior-lisp-proc):
* lisp/progmodes/idlwave.el (idlwave-beginning-of-statement)
(idlwave-template, idlwave-update-buffer-routine-info)
(idlwave-update-current-buffer-info)
(idlwave-get-routine-info-from-buffers, idlwave-choose)
(idlwave-scan-class-info, idlwave-fix-keywords)
(idlwave-list-buffer-load-path-shadows):
* lisp/progmodes/idlw-toolbar.el (idlwave-toolbar, idlwave-toolbar-add)
(idlwave-toolbar-remove):
* lisp/progmodes/idlw-shell.el (idlwave-shell-save-and-action)
(idlwave-shell-file-name, idlwave-shell-electric-debug-all-off)
(idlwave-shell-menu-def):
* lisp/progmodes/idlw-complete-structtag.el
(idlwave-prepare-structure-tag-completion):
* lisp/progmodes/gud.el (gud-set-buffer):
* lisp/progmodes/f90.el (f90-backslash-not-special):
* lisp/progmodes/delphi.el (delphi-find-unit): Use derived-mode-p.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 10 Dec 2010 15:00:25 -0500 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
54695 | 1 ;;; url-methods.el --- Load URL schemes as needed |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
5 |
54695 | 6 ;; Keywords: comm, data, processes, hypermedia |
7 | |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
9 |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
13 ;; (at your option) any later version. |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
14 |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
18 ;; GNU General Public License for more details. |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
19 |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
22 |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
23 ;;; Commentary: |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
24 |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
25 ;;; Code: |
54695 | 26 |
27 (eval-when-compile | |
28 (require 'cl)) | |
29 | |
30 ;; This loads up some of the small, silly URLs that I really don't | |
31 ;; want to bother putting in their own separate files. | |
32 (require 'url-parse) | |
33 | |
34 (defvar url-scheme-registry (make-hash-table :size 7 :test 'equal)) | |
35 | |
36 (defconst url-scheme-methods | |
37 '((default-port . variable) | |
38 (asynchronous-p . variable) | |
39 (expand-file-name . function) | |
40 (file-exists-p . function) | |
41 (file-attributes . function) | |
42 (parse-url . function) | |
43 (file-symlink-p . function) | |
44 (file-writable-p . function) | |
45 (file-directory-p . function) | |
46 (file-executable-p . function) | |
47 (directory-files . function) | |
48 (file-truename . function)) | |
49 "Assoc-list of methods that each URL loader can provide.") | |
50 | |
51 (defconst url-scheme-default-properties | |
52 (list 'name "unknown" | |
53 'loader 'url-scheme-default-loader | |
54 'default-port 0 | |
55 'expand-file-name 'url-identity-expander | |
56 'parse-url 'url-generic-parse-url | |
57 'asynchronous-p nil | |
58 'file-directory-p 'ignore | |
59 'file-truename (lambda (&rest args) | |
60 (url-recreate-url (car args))) | |
61 'file-exists-p 'ignore | |
62 'file-attributes 'ignore)) | |
63 | |
64 (defun url-scheme-default-loader (url &optional callback cbargs) | |
65 "Signal an error for an unknown URL scheme." | |
66 (error "Unkown URL scheme: %s" (url-type url))) | |
67 | |
104970
fb38af38e1ff
* url-methods.el (url-scheme--registering-proxy): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
68 (defvar url-scheme--registering-proxy nil) |
fb38af38e1ff
* url-methods.el (url-scheme--registering-proxy): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
69 |
54695 | 70 (defun url-scheme-register-proxy (scheme) |
71 "Automatically find a proxy for SCHEME and put it in `url-proxy-services'." | |
72 (let* ((env-var (concat scheme "_proxy")) | |
73 (env-proxy (or (getenv (upcase env-var)) | |
74 (getenv (downcase env-var)))) | |
75 (cur-proxy (assoc scheme url-proxy-services)) | |
104970
fb38af38e1ff
* url-methods.el (url-scheme--registering-proxy): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
76 (urlobj nil) |
fb38af38e1ff
* url-methods.el (url-scheme--registering-proxy): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
77 (url-scheme--registering-proxy t)) |
54695 | 78 |
72958
3b2d4cd42aaa
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
Miles Bader <miles@gnu.org>
parents:
68640
diff
changeset
|
79 ;; If env-proxy is an empty string, treat it as if it were nil |
3b2d4cd42aaa
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
Miles Bader <miles@gnu.org>
parents:
68640
diff
changeset
|
80 (when (and (stringp env-proxy) |
3b2d4cd42aaa
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
Miles Bader <miles@gnu.org>
parents:
68640
diff
changeset
|
81 (string= env-proxy "")) |
3b2d4cd42aaa
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
Miles Bader <miles@gnu.org>
parents:
68640
diff
changeset
|
82 (setq env-proxy nil)) |
3b2d4cd42aaa
lisp/url/url-methods.el: Fix format error when http_proxy is empty string
Miles Bader <miles@gnu.org>
parents:
68640
diff
changeset
|
83 |
54695 | 84 ;; Store any proxying information - this will not overwrite an old |
85 ;; entry, so that people can still set this information in their | |
86 ;; .emacs file | |
87 (cond | |
88 (cur-proxy nil) ; Keep their old settings | |
89 ((null env-proxy) nil) ; No proxy setup | |
90 ;; First check if its something like hostname:port | |
91 ((string-match "^\\([^:]+\\):\\([0-9]+\\)$" env-proxy) | |
92 (setq urlobj (url-generic-parse-url nil)) ; Get a blank object | |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
93 (setf (url-type urlobj) "http") |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
94 (setf (url-host urlobj) (match-string 1 env-proxy)) |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
95 (setf (url-port urlobj) (string-to-number (match-string 2 env-proxy)))) |
54695 | 96 ;; Then check if its a fully specified URL |
97 ((string-match url-nonrelative-link env-proxy) | |
98 (setq urlobj (url-generic-parse-url env-proxy)) | |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
99 (setf (url-type urlobj) "http") |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
100 (setf (url-target urlobj) nil)) |
54695 | 101 ;; Finally, fall back on the assumption that its just a hostname |
102 (t | |
103 (setq urlobj (url-generic-parse-url nil)) ; Get a blank object | |
83823
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
104 (setf (url-type urlobj) "http") |
dd2bcc6758a0
* url-parse.el (url): Use defstruct rather than macros. Update all callers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78222
diff
changeset
|
105 (setf (url-host urlobj) env-proxy))) |
54695 | 106 |
107 (if (and (not cur-proxy) urlobj) | |
108 (progn | |
109 (setq url-proxy-services | |
110 (cons (cons scheme (format "%s:%d" (url-host urlobj) | |
111 (url-port urlobj))) | |
112 url-proxy-services)) | |
113 (message "Using a proxy for %s..." scheme))))) | |
114 | |
115 (defun url-scheme-get-property (scheme property) | |
96486
7369ded3b436
Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
94668
diff
changeset
|
116 "Get PROPERTY of a URL SCHEME. |
54695 | 117 Will automatically try to load a backend from url-SCHEME.el if |
118 it has not already been loaded." | |
119 (setq scheme (downcase scheme)) | |
120 (let ((desc (gethash scheme url-scheme-registry))) | |
121 (if (not desc) | |
122 (let* ((stub (concat "url-" scheme)) | |
123 (loader (intern stub))) | |
124 (condition-case () | |
125 (require loader) | |
126 (error nil)) | |
127 (if (fboundp loader) | |
128 (progn | |
129 ;; Found the module to handle <scheme> URLs | |
104970
fb38af38e1ff
* url-methods.el (url-scheme--registering-proxy): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
130 (unless url-scheme--registering-proxy |
fb38af38e1ff
* url-methods.el (url-scheme--registering-proxy): New variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
131 (url-scheme-register-proxy scheme)) |
54695 | 132 (setq desc (list 'name scheme |
133 'loader loader)) | |
134 (dolist (cell url-scheme-methods) | |
135 (let ((symbol (intern-soft (format "%s-%s" stub (car cell)))) | |
136 (type (cdr cell))) | |
137 (if symbol | |
138 (case type | |
139 (function | |
140 ;; Store the symbol name of a function | |
141 (if (fboundp symbol) | |
142 (setq desc (plist-put desc (car cell) symbol)))) | |
143 (variable | |
144 ;; Store the VALUE of a variable | |
145 (if (boundp symbol) | |
146 (setq desc (plist-put desc (car cell) | |
147 (symbol-value symbol))))) | |
148 (otherwise | |
149 (error "Malformed url-scheme-methods entry: %S" | |
150 cell)))))) | |
151 (puthash scheme desc url-scheme-registry))))) | |
152 (or (plist-get desc property) | |
153 (plist-get url-scheme-default-properties property)))) | |
154 | |
155 (provide 'url-methods) | |
54699 | 156 |
54831
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
157 ;; arch-tag: 336863f8-5a07-4906-9be5-b3c6bcebbe67 |
ca18766bb266
Comment fixups.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
158 ;;; url-methods.el ends here |