Hi, Attached are five minor patches.
The most useful one fixes a couple of major irritations for me in the emacs mode with regards the indentation of XML. I have only tested it on emacs 25 so far, though, so feedback on its validity on earlier versions of emacs would be appreciated.
# HG changeset patch # User Julian Squires <[email protected]> # Date 1430764507 14400 # Mon May 04 14:35:07 2015 -0400 # Node ID 790b14db7055570fcb323adf00ae1f453c88fa5e # Parent 67b863c26df61045fa5c356957018e8e668c3d65 Fix XML indentation in Emacs mode The return value of MATCH-STRING is a string. At least on Emacs 25, the comparisons between string and character with EQUAL could never succeed, and so the cases for matching braces were never triggered. GET-TEXT-PROPERTY may return a list rather than an atom (for example, on long lines with whitespace-mode turned on), and this broke the heuristic of looking for the tag face in previous text. diff -r 67b863c26df6 -r 790b14db7055 src/elisp/urweb-mode.el --- a/src/elisp/urweb-mode.el Mon May 04 13:22:29 2015 -0400 +++ b/src/elisp/urweb-mode.el Mon May 04 14:35:07 2015 -0400 @@ -179,11 +179,11 @@ (let ((xml-tag (length (or (match-string 3) ""))) (ch (match-string 2))) (cond - ((equal ch ?\{) + ((equal ch "{") (if (> depth 0) (decf depth) (setq finished t))) - ((equal ch ?\}) + ((equal ch "}") (incf depth)) ((= xml-tag 3) (if (> depth 0) @@ -194,14 +194,14 @@ ((= xml-tag 4) (incf depth)) - ((equal ch ?-) + ((equal ch "-") (if (looking-at "->") (setq finished (= depth 0)))) ((and (= depth 0) (not (looking-at "<xml")) ;; ignore <xml/> - (eq font-lock-tag-face - (get-text-property (point) 'face))) + (let ((face (get-text-property (point) 'face))) + (funcall (if (listp face) #'member #'equal) 'font-lock-tag-face face))) ;; previous code was highlighted as tag, seems we are in xml (progn (setq answer t)
The second adds an urweb-close-matching-tag command to the emacs mode. This is a small convenience inspired by nxml-mode's nxml-finish-element, with the same binding (C-c /).
# HG changeset patch # User Julian Squires <[email protected]> # Date 1430770501 14400 # Mon May 04 16:15:01 2015 -0400 # Node ID a82e3ccd5d81aec29ce24f839d54f0def9e5c5b2 # Parent 92f40169c47428993a7cd2afb5ab4331183a2cfe Add urweb-mode command to close current XML tag Bound to "C-c /" by default to match nxml-mode's nxml-finish-element command. diff -r 92f40169c474 -r a82e3ccd5d81 src/elisp/urweb-mode.el --- a/src/elisp/urweb-mode.el Mon May 04 14:58:24 2015 -0400 +++ b/src/elisp/urweb-mode.el Mon May 04 16:15:01 2015 -0400 @@ -401,6 +401,7 @@ (unless (boundp 'skeleton-positions) (set (make-local-variable '@) nil)) (local-set-key (kbd "C-c C-c") 'compile) + (local-set-key (kbd "C-c /") 'urweb-close-matching-tag) (urweb-mode-variables)) @@ -542,6 +543,16 @@ (beginning-of-line) (current-indentation))) +(defun urweb-close-matching-tag () + "Insert a closing XML tag for whatever tag is open at the point." + (interactive) + (assert (urweb-in-xml)) + (save-excursion + (urweb-tag-matcher) + (re-search-forward "<\\([^ ={/>]+\\)" nil t)) + (let ((tag (match-string-no-properties 1))) + (insert "</" tag ">"))) + (defconst urweb-sql-main-starters '("SQL" "SELECT" "INSERT" "UPDATE" "DELETE" "FROM" "SELECT1" "WHERE"))
The third adds the "style" keyword as starting an expression in the emacs mode. Otherwise, any style following another expression will be indented incorrectly.
# HG changeset patch # User Julian Squires <[email protected]> # Date 1430765904 14400 # Mon May 04 14:58:24 2015 -0400 # Node ID 92f40169c47428993a7cd2afb5ab4331183a2cfe # Parent 790b14db7055570fcb323adf00ae1f453c88fa5e Treat "style" as starting an expression in urweb-mode diff -r 790b14db7055 -r 92f40169c474 src/elisp/urweb-defs.el --- a/src/elisp/urweb-defs.el Mon May 04 14:35:07 2015 -0400 +++ b/src/elisp/urweb-defs.el Mon May 04 14:58:24 2015 -0400 @@ -108,7 +108,7 @@ "datatype" "type" "open" "include" urweb-module-head-syms "con" "map" "where" "extern" "constraint" "constraints" - "table" "sequence" "class" "cookie" "task" "policy") + "table" "sequence" "class" "cookie" "task" "policy" "style") "Symbols starting an sexp.") ;; (defconst urweb-not-arg-start-re
Hopefully I will have the chance to fix the indentation of table constraints soon. The fourth patch attached adds the <fieldset> and <legend> tags, in the most trivial way. This was enough for my needs so far, but I'm already realizing that this is probably not sufficient -- at the very least, fieldset needs to support the disabled attribute. I'm attaching it anyway to open discussion about it.
# HG changeset patch # User Julian Squires <[email protected]> # Date 1430760149 14400 # Mon May 04 13:22:29 2015 -0400 # Node ID 67b863c26df61045fa5c356957018e8e668c3d65 # Parent 9a9a8225672aaf48227ec1f903b23356fbfcf74d Add fieldset and legend tags diff -r 9a9a8225672a -r 67b863c26df6 lib/ur/basis.urs --- a/lib/ur/basis.urs Fri Apr 24 16:21:55 2015 -0400 +++ b/lib/ur/basis.urs Mon May 04 13:22:29 2015 -0400 @@ -1028,6 +1028,9 @@ val label : bodyTag ([For = id, Accesskey = string] ++ tableAttrs) +val fieldset : bodyTag boxAttrs +val legend : bodyTag boxAttrs + (*** AJAX-oriented widgets *)
Finally, it seems to me that any URI specified by a "file" directive is implicitly one that one intends to "allow". The last patch does this. I can see how my assumption here might be contrary to the Ur/Web Way, though.
# HG changeset patch # User Julian Squires <[email protected]> # Date 1429906915 14400 # Fri Apr 24 16:21:55 2015 -0400 # Node ID 3e9753b8343eefd21664ee36aa455c20783fe9c3 # Parent ef778f9e2d3b9d3dd00ae2bf6080c84e87bd4b6f Allow URIs specified in file directives implicitly It seems to me that, by specifying that one wants to serve a given file at a specified URI, one is implying that this URI should be allowed. diff -r ef778f9e2d3b -r 3e9753b8343e src/compiler.sml --- a/src/compiler.sml Fri Apr 24 07:51:47 2015 -0400 +++ b/src/compiler.sml Fri Apr 24 16:21:55 2015 -0400 @@ -875,7 +875,8 @@ (case String.fields Char.isSpace arg of [uri, fname] => (Settings.setFilePath thisPath; Settings.addFile {Uri = uri, - LoadFromFilename = fname}) + LoadFromFilename = fname}; + url := {action = Settings.Allow, kind = Settings.Exact, pattern = uri} :: !url) | _ => ErrorMsg.error "Bad 'file' arguments") | _ => ErrorMsg.error ("Unrecognized command '" ^ cmd ^ "'");
I'll try to avoid grouping unrelated patches together in future emails to the list; I just wanted to avoid spamming the list with messages for such small patches. Thanks, -- Julian Squires
_______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
