;;header's value is (696 . 3) ;;string's value is ;;"696 (gnuserv-edit-files-quickly '((1 . \"c:/emacs-lisp/nxhtml/temp.htmlf\")))" ;; (let ((tb (get-file-buffer "c:/emacs-lisp/nxhtml/temp.htmlf"))) ;; (when tb ;; (message "killing buffer")(sit-for 2) ;; (kill-buffer tb))) ;; (let* ((header '(696 . 3)) ;; (string "696 (gnuserv-edit-files-quickly '((1 . \"c:/emacs-lisp/nxhtml/temp.htmlf\")))") ;; (to-eval (car (read-from-string string ;; (cdr header)))) ;; ) ;; (message "%s" to-eval) ;; (eval to-eval)) ;; (let ((mode (assoc-default ".htmlf" xmlpe-mode-alist 'string-match))) ;; (message "mode=%s" mode)(sit-for 2) ;; (message "cdr mode=%s" (cdr mode))(sit-for 2) ;; (consp mode) ;; (cadr mode)) ;; (eval (car (read-from-string gnuserv-string ;; (cdr header)))) ;; (defun rng-make-attribute (name-class pattern) ;; (message "ATTRIBUTE: name-class=%s, pattern=%s" name-class pattern) ;; ;;(sit-for 2) ;; (list 'attribute name-class pattern)) ;; (defun rng-make-data (name params) ;; (message "DATA: name=%s, params=%s" name params) ;; (list 'data name params)) ;; (defun rng-make-value (datatype str context) ;; (message "VALUE: datatype=%s, str=%s, context=%s" datatype str context) ;; (list 'value datatype str context)) ;; (defvar temp-n 0) ;; (defadvice rng-make-element (before nxhtml-rng-make-element-ad ;; (name-class pattern) ;; activate) ;; (when (< temp-n 50) ;; (setq temp-n (1+ temp-n)) ;; (condition-case nil ;; (let ((s (format "ELEMENT: name-class=%s, pattern=%s" name-class pattern))) ;; (when (string-match "img" s) ;; (message "%s" s))) ;; (error nil)))) ;; (defadvice rng-c-parse-top-level (after nxhtml-rng-c-parse-top-level-ad ;; (context) ;; activate) ;; (message "rng-c-datatype-decls=%s" rng-c-datatype-decls) ;; ) ;; (setq default-directory "d:/test/etc/img/") ;;var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; (defvar nxhtml-predicate-error nil) (defun nxhtml-mailto-predicate(url) "Tries to match a mailto url. This is not supposed to be entirely correct." (setq nxhtml-predicate-error nil) ;; Local pattern copied from gnus. (let ((r (concat "^" ;;"mailto:" "[a-z0-9$%(*-=?[_][^<>\")!;:,{}]*" "\@" "\\(?:[a-z0-9\-]+\.\\)+[a-z0-9]\\{2,4\\}$")) (case-fold-search t)) ;;(message "mailpred") (sit-for 1) (if (string-match r url) t (setq nxhtml-predicate-error "Malformed email address.") nil))) (defcustom nxhtml-image-completion-pattern "\\.\\(?:png\\|jpg\\|jpeg\\|gif\\)$" "Pattern for matching image URLs in completion." :type 'regexp) (defun nxhtml-image-url-predicate(url) (setq nxhtml-predicate-error nil) (if (or (file-directory-p url) (string-match nxhtml-image-completion-pattern url)) t (setq nxhtml-predicate-error "Does not match image file name pattern.") nil )) (defcustom nxhtml-script-completion-pattern "\\.\\(?:js\\)$" "Pattern for matching src URLs in completion in script tags." :type 'regexp) (defun nxhtml-script-url-predicate(url) (setq nxhtml-predicate-error nil) (if (or (file-directory-p url) (string-match nxhtml-script-completion-pattern url)) t (setq nxhtml-predicate-error "Does not match script file name pattern.") nil )) (defun nxhtml-href-url-predicate(url) (setq nxhtml-predicate-error nil) (let* ((purl (url-generic-parse-url url)) (host (elt purl 0))) (if (string= "mailto" host) (nxhtml-mailto-predicate url) t))) (defun nxhtml-read-url-type-help() (interactive) (let ((name "*URL Type Help*")) (with-output-to-temp-buffer name (princ "Help for URL type choice:\n\n") (princ "Type just one letter to choose URL type. ") (princ "This will affect prompting and in some cases do basic checks. ") (princ "\n\n") (princ "Use C-g to quit.") (with-current-buffer name (fill-region (point-min) (point-max)))))) (defun nxhtml-read-url-type(allowed url-beginning) (let ((prompt "URL-type (") (map (make-sparse-keymap)) (beg-type (elt (url-generic-parse-url url-beginning) 0)) choice) (define-key map "?" 'nxhtml-read-url-type-help) (define-key map [(control ?g)] 'abort-recursive-edit) (define-key map [t] 'ignore) (cond ((string= "mailto" beg-type) (setq allowed '(?m))) ((or (string= "http" beg-type) (string= "https" beg-type) (string= "ftp" beg-type)) (setq allowed '(?w))) ((= 1 (length beg-type)) ;; w32 (setq allowed '(?f))) ) (if allowed (when (eq allowed t) (setq allowed '(?f ?w ?m))) (setq allowed '(?f ?w))) (if (= 1 (length allowed)) (setq choice (car allowed)) (when (memq ?f allowed) (define-key map "f" 'exit-minibuffer) (setq prompt (concat prompt "f-local file, "))) (when (memq ?m allowed) (define-key map "m" 'exit-minibuffer) (setq prompt (concat prompt "m-mail, "))) (when (memq ?w allowed) (define-key map "w" 'exit-minibuffer) (setq prompt (concat prompt "w-web url, "))) (setq prompt (concat prompt "? for help): ")) (read-from-minibuffer prompt nil map) (setq choice last-input-char)) (cond ((memq choice '(?f ?F)) 'local-file-url) ((memq choice '(?w ?W)) 'web-url) ((memq choice '(?m ?M)) 'mail-url) ))) (defun nxhtml-read-web-url(&optional initial-contents predicate) ) (defvar nxhtml-read-url-history nil) (defvar nxhtml-read-web-url-history nil) (defvar nxhtml-read-mail-url-history nil) (defun nxhtml-read-url(&optional allowed-types initial-contents extra-predicate prompt-prefix) (let* ((url-type (nxhtml-read-url-type allowed-types initial-contents)) (base-prompt (cond ((eq url-type 'local-file-url) "File: ") ((eq url-type 'web-url) "Web URL: ") ((eq url-type 'mail-url) "e-Mail address: ") ((eq url-type 'any-url) "Any URL-type: ") (t (error "Internal error: bad url-type=%s" url-type)))) prompt type-predicate url (bad-url initial-contents) (default-directory (if buffer-file-name (file-name-directory buffer-file-name) default-directory))) (when prompt-prefix (setq base-prompt (concat prompt-prefix " " base-prompt))) (setq nxhtml-predicate-error "") (cond ((eq url-type 'local-file-url) ) ((eq url-type 'web-url) ) ((eq url-type 'mail-url) (setq type-predicate 'nxhtml-mailto-predicate) (when (and (stringp bad-url) (<= 7 (length bad-url)) (string= "mailto:" (substring bad-url 0 7))) (setq bad-url (substring bad-url 7))) ) ) (while (not url) (setq prompt (concat nxhtml-predicate-error " " base-prompt)) (cond ((eq url-type 'local-file-url) (setq url (read-file-name prompt nil "" nil bad-url extra-predicate)) (when (< 0 (length url)) (setq url (file-relative-name (expand-file-name url))))) ((eq url-type 'web-url) (setq url (read-from-minibuffer prompt bad-url nil nil 'nxhtml-read-web-url-history t))) ((eq url-type 'mail-url) (setq url (read-from-minibuffer prompt bad-url nil nil 'nxhtml-read-mail-url-history t))) (t (setq url (read-from-minibuffer prompt bad-url nil nil 'nxhtml-read-url-history t)))) (when (or (and type-predicate (not (funcall type-predicate url))) (and extra-predicate (not (funcall extra-predicate url)))) (setq bad-url url) (setq url))) (when (eq url-type 'mail-url) (setq url (concat "mailto:" url))) url)) ;; (defvar nxhtml-hide-error-delay 2) ;; (defun nxhtml-hide-error-msg() ;; (sit-for nxhtml-hide-error-delay) ;; ;;(message "") ;; ) (defconst nxhtml-in-xml-attribute-value-regex (replace-regexp-in-string "w" xmltok-ncname-regexp ;;"= n 0) (message "myback-text: %s" (backtrace-frame n)) ;;(sit-for 2) (setq n 7) (let ((s "")) (while (< n 15) (setq n (1+ n)) (setq s (concat s (format "myback-text %s: %s\n" n (backtrace-frame n))))) (message "%s" s)) (sit-for 2) ) ;;(message "myback trace: %s" (with-output-to-string (backtrace))) ) (defun test-ad() t) (defadvice test-ad(around test-ad-ad () activate) (setq ad-return-value t)) (defun test-read() (read-from-minibuffer "Testing ? for help: " nil nxhtml-href-completion-map) last-input-char) (defun nxhtml-coding-systems-complete(init default) (let ((coding-systems (mapcar (lambda(coding-system) (symbol-name (coding-system-get coding-system 'mime-charset))) (coding-system-list t)))) (completing-read "Coding system: " coding-systems nil t init nil default)))