{"action":"created","issue":{"url":"https://api.github.com/repos/company-mode/company-mode/issues/537","repository_url":"https://api.github.com/repos/company-mode/company-mode","labels_url":"https://api.github.com/repos/company-mode/company-mode/issues/537/labels{/name}","comments_url":"https://api.github.com/repos/company-mode/company-mode/issues/537/comments","events_url":"https://api.github.com/repos/company-mode/company-mode/issues/537/events","html_url":"https://github.com/company-mode/company-mode/pull/537","id":158985493,"number":537,"title":"Make company-nxml backend more schema aware","user":{"login":"tplass","id":19796884,"avatar_url":"https://avatars.githubusercontent.com/u/19796884?v=3","gravatar_id":"","url":"https://api.github.com/users/tplass","html_url":"https://github.com/tplass","followers_url":"https://api.github.com/users/tplass/followers","following_url":"https://api.github.com/users/tplass/following{/other_user}","gists_url":"https://api.github.com/users/tplass/gists{/gist_id}","starred_url":"https://api.github.com/users/tplass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tplass/subscriptions","organizations_url":"https://api.github.com/users/tplass/orgs","repos_url":"https://api.github.com/users/tplass/repos","events_url":"https://api.github.com/users/tplass/events{/privacy}","received_events_url":"https://api.github.com/users/tplass/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":34,"created_at":"2016-06-07T17:56:42Z","updated_at":"2016-07-12T18:50:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/company-mode/company-mode/pulls/537","html_url":"https://github.com/company-mode/company-mode/pull/537","diff_url":"https://github.com/company-mode/company-mode/pull/537.diff","patch_url":"https://github.com/company-mode/company-mode/pull/537.patch"},"body":"With a RELAX NG schema loaded for the current buffer completion is more \r\ncontext sensitive and schema aware.\r\n\r\nWhen in tag name context (after a '<'), requesting completion will\r\n * auto-insert the next required element or default to presenting the candidate \r\n   list of optional elements along with the end tag for the current element\r\n * auto-insert all required attributes\r\n * prepare the next completion request to either\r\n   * auto-insert the sole optional attribute or \r\n   * present the candidate list of optional attribute names. \r\n\r\n   This requires that the last completion action inserted a tag name but does\r\n   not require a space to be manually inserted after the tag name.\r\n\r\nAttributes are always inserted as attname=\"\" with point positioned after the first quote.\r\n\r\nAttribute completion is available at all legal positions in open as well as already\r\nclosed tags.\r\n"},"comment":{"url":"https://api.github.com/repos/company-mode/company-mode/issues/comments/232142948","html_url":"https://github.com/company-mode/company-mode/pull/537#issuecomment-232142948","issue_url":"https://api.github.com/repos/company-mode/company-mode/issues/537","id":232142948,"user":{"login":"tplass","id":19796884,"avatar_url":"https://avatars.githubusercontent.com/u/19796884?v=3","gravatar_id":"","url":"https://api.github.com/users/tplass","html_url":"https://github.com/tplass","followers_url":"https://api.github.com/users/tplass/followers","following_url":"https://api.github.com/users/tplass/following{/other_user}","gists_url":"https://api.github.com/users/tplass/gists{/gist_id}","starred_url":"https://api.github.com/users/tplass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tplass/subscriptions","organizations_url":"https://api.github.com/users/tplass/orgs","repos_url":"https://api.github.com/users/tplass/repos","events_url":"https://api.github.com/users/tplass/events{/privacy}","received_events_url":"https://api.github.com/users/tplass/received_events","type":"User","site_admin":false},"created_at":"2016-07-12T18:50:20Z","updated_at":"2016-07-12T18:50:20Z","body":"After quite some testing and learning to appreciate what `(backtrace)`\r\ndoes to debugging, I've been able to fix and extend the functionality\r\nof `company-nxml`.\r\n\r\nBefore I commit any changes, I'd like to get some feedback on how to\r\nproceed in the light of my findings and changes to the current\r\n`nxml-mode`.\r\n\r\nFirst, I finally tracked down the cause of the strange behaviour when\r\ndespite `company-candidates` being a list, no tooltip was shown but\r\ninstead the first candidate auto-inserted.\r\n\r\n\r\n```elisp\r\n(defun company-complete ()\r\n  \"Insert the common part of all candidates or the current selection.\r\nThe first time this is called, the common part is inserted, the second\r\ntime, or when the selection has been changed, the selected candidate is\r\ninserted.\"\r\n  (interactive)\r\n  (when (company-manual-begin)\r\n    (if (or company-selection-changed\r\n            (eq last-command 'company-complete-common))\r\n        (call-interactively 'company-complete-selection)\r\n                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n      (call-interactively 'company-complete-common)\r\n      (setq this-command 'company-complete-common))))\r\n```\r\n\r\nSo, two completion requests immediately following each other would be\r\nredirected into different directions.  And along the way\r\n`company-complete-selection` would do a `(setq company-selection 0)`\r\nwhich selects the first candidate.\r\n\r\nNow, switching between `company-complete-common` and\r\n`company-complete-selection` is probably a design choice of `company`.\r\nBut for my backend, this is a showstopper as the user cannot use\r\n`company-complete` on his keybinding but is forced to use\r\n`company-manual-begin` or directly `company-complete-common`.\r\n\r\n**First question**: Is there any way (except maybe some screwy\r\n`defadvice`ing around `company-complete`) to enable a backend to set\r\n`this-command` to whatever it sees fit?  If not, there's no point for\r\nme to continue with this project.  Or could you add a variable that\r\nwould stop `company-complete` from switching between states?\r\n\r\nThe second big improvement for `company-nxml` is the support of XML\r\nnamespaces which is utterly missing from the production. This means\r\nthat currently only non-namespace XML schemas are supported.  E.g., it\r\nis simply impossible to use `company` completion for editing XSLT\r\nstylesheets as candidates are missing the \"xsl:\" namespace prefix.\r\nAnd there's more that fails due to this shortcoming.\r\n\r\nI therefore completely revamped the main XML functions by essentially\r\ncalling `nxml` functions and let *it* compute the candidates as well as\r\nsteal^H^H^H^H^H repurposing some of the code that does support work.\r\n\r\nThe `nxml` code for this has changed incompatibly from my Emacs\r\n(25.0.50.1) to the version formerly known as 26 (which is now called\r\n25.2?!).  However, only a few trivial changes were necessary to port\r\nmy code to the current `nxml` code base.\r\n\r\n**So, my next question is**: does it make any sense at all to ship an\r\nupdated `company-nxml` in the light of the different incompatible\r\nversions of `nxml`?\r\n\r\nOh btw, the completion implemented for the current master `nxml` is\r\njust as basic and IMHO \"broken\" as it ever was.  That's why at least\r\n*I* will continue to enjoy `company`.\r\n\r\n"}}
{"actor":{"display_login":"tplass"}}