Guest User

Untitled

a guest
Jun 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.44 KB | None | 0 0
  1. =================
  2. = Configuration =
  3. =================
  4.  
  5. =========
  6. = Terms =
  7. =========
  8.  
  9. A `Default` Package:
  10.  
  11. This isn't neccessarily just the Packages/Default package
  12. literally named "Default".
  13.  
  14. Through-out I'll put `Default` in backquotes when I mention any
  15. Packages that are defaults, ie those that come stock with Sublime.
  16.  
  17. This includes the Python / HTML / JavaScript packages etc
  18.  
  19. `asset`:
  20.  
  21. A sublime-snippet / sublime-keymap etc inside a Package.
  22.  
  23. ============
  24. = Problems =
  25. ============
  26.  
  27. Exhibit a) A harmless try/except/finally python snippet
  28.  
  29. <snippet>
  30. <content><![CDATA[try:
  31. ${1:pass}
  32. except ${2:Exception}, ${3:e}:
  33. ${4:raise $3}
  34. finally:
  35. ${5:pass}]]></content>
  36. <tabTrigger>try</tabTrigger>
  37. <scope>source.python</scope>
  38. <description>Try/Except/Finally</description>
  39. </snippet>
  40.  
  41. Scenario 1
  42. ----------
  43.  
  44. I'm a typical new user. I'm not using the AutomaticBackups plugin and
  45. I'm definitely not using version control.
  46.  
  47. *) I'd like to modify the snippet from exhibit A to change the default
  48. value of tabstop 1 to $SELECTION. I do so.
  49.  
  50. *) It's convenient to just save the snippet in place over writing
  51. the package version so I do so.
  52.  
  53. *) Months and a few betas pass. All is fine in the land.
  54.  
  55. *) A new beta comes out and the official `Default` Python Package version of
  56. the asset gets updated (maybe using new inline Python in the snippets)
  57.  
  58. *) On update my modification gets hosed (silently) along with about 12
  59. other various assets.
  60.  
  61. *) I wasn't notified of the updates and they were overwritten silently
  62. so I only find out the extent of the problem as I go to use my
  63. snippets / assets.
  64.  
  65. Scenario 2
  66. ----------
  67.  
  68. I have been using Sublime for a while and have been bitten by the
  69. `silent updates`. I generally use version control on updates (when I
  70. remember to!).
  71.  
  72. *) I'd like to modify the snippet from exhibit A to change the default value of
  73. tabstop 1 to $SELECTION. I do so.
  74.  
  75. *) Where do I save? Like a good citizen, I save it in the User
  76. folder, trying to avoid any possibility whatsoever of overwrites on
  77. package updates.
  78.  
  79. *) Having saved the snippet in my User folder I go to use the
  80. snippet. There are about 5 snippets with a <tabTrigger> of "try" so
  81. I now have a duplicate in the `quick panel` for each try/except/* snippet
  82. I modify.
  83.  
  84. The only way I can remove it is modifying the original file ( by deleting
  85. it or commenting out the <tabTrigger> )
  86.  
  87. Steps needed for this process:
  88.  
  89. * P[r]eferences - Browse Packages
  90.  
  91. * Find the snippet
  92.  
  93. * Copy it manually into the python folder
  94.  
  95. * Edit it
  96.  
  97. * Delete/comment the original
  98.  
  99. * Repeat process after every update to the asset
  100.  
  101. Scenario 3
  102. ----------
  103.  
  104. I want to tweak a binding declared in one of the `Default` packages
  105. sublime- keymap file. We'll say HTML.sublime-keymap for example but
  106. really the discerning point is that it's a `Default` sublime-keymap
  107. where it's possible it will get over-written silently.
  108.  
  109. I've been hosed before so I'd like to place my binding in the `User`
  110. sublime-keymap in case I forget to commit/backup before update.
  111.  
  112. Steps needed for this process:
  113.  
  114. * Per File Type->HTML
  115.  
  116. * Find the binding in question
  117.  
  118. * Copy the binding
  119.  
  120. * Per File Type->User
  121.  
  122. * Paste in the binding
  123.  
  124. ==========================
  125. = Essence Of The Problem =
  126. ==========================
  127.  
  128. * Users are encourage to modify `Default` package assets such as
  129. the Python/Default.sublime-keymap and not really warned that it's possible
  130. their changes will be over written silently
  131.  
  132. * It's simply a pain navigating back and forth copy/pasting & saving
  133. copies to the User folder.
  134.  
  135. * No automatic merge of user modified assets (by unique key of fileName or UUID)
  136.  
  137. ====================
  138. = Desired Outcomes =
  139. ====================
  140.  
  141. * Maintain `hand editability` and aesthetics
  142.  
  143. * no ugly and hard to work with uuid
  144.  
  145. * no mousing about with clicky menu types
  146.  
  147. * No losing of modified package `assets`
  148.  
  149. * Notification of when modified package `assets` are updated
  150. ( ie change from `pristine` (earlier) version to
  151. `latest` version ). If you have `forked off` from the mainline
  152. you should be notified of any updates to the mainline which
  153. you may / may not want to incorporate.
  154.  
  155. =============
  156. = Solutions =
  157. =============
  158.  
  159. 1) Leave configuration `as is`, editing `Default` package assets in
  160. place and use `update hooks` for external merge/diff tools to
  161. manage changes.
  162.  
  163. 2) Leave config essentially as is but develop `asset cloning`
  164. commands to clone assets from `Default` packages.
  165.  
  166. 3) Combinations of the above two
  167.  
  168. 4) Include UUIDs in assets and create a Package asset manager using
  169. Virtual Views and QuickPanel navigation.
  170.  
  171. Update Hooks
  172. ============
  173.  
  174. Hook points for integrating version control. This could be done simply
  175. with subprocess calls to svn/ hg/ vcs of choice. Possibly even custom
  176. sublime-keymap diff/merge tools could be developed using lxml etc.
  177.  
  178. def preUpdate(window): pass
  179. """ hooks for add/commit etc """
  180.  
  181. def postUpdate(window): pass
  182. """ hooks for things like 'hg status -m;hg status -a` or even
  183. calls to merge tools etc """
  184.  
  185. If these `singular` hooks aren't over-ridden then the builtin default
  186. hook would present a basic report of changes, also setting a flag for
  187. the upgrade script to make backups to overwrites of 'user modified'
  188. assets. This is the very least that needs to be done. Having silent
  189. overwrites is unacceptable.
  190.  
  191. Sublime's configurations paradigm, having no real configuration menus,
  192. is definitely oriented towards `power` users. I don't think it's
  193. stretch having them do assisted merges of configuration on update. I
  194. think this would be relatively simple to implement and the
  195. participation required would naturally scale according to a users
  196. configuration needs.
  197.  
  198. A new user would hardly modify anything so wouldn't get bothered (or
  199. confused ) by any update reports. Intermediates would benefit by
  200. learning a bit more about what's going on and long time users would
  201. appreciate the `updates`.
  202.  
  203. User Asset Cloning
  204. ==================
  205.  
  206. The `best practice` is to keep *all* your key-bindings in the
  207. Packages/User/XXXXX.sublime-keymap file. ( typically Default )
  208.  
  209. If this is the case, then there needs to be some type of support
  210. present for editing `existing` keybindings. Rather than opening up the
  211. Python/*keymap and copy/pasting a binding into your User/*keymap a
  212. `cloneBinding` command to do it automatically ( commenting out the
  213. `master` binding ) and take you to the edit point would be nice.
  214.  
  215. Otherwise, this is a `paint point` where a lot of potential purchasers
  216. of the software walk away. You could have a quick-panel to list all
  217. the bindings for editing (cloning) as well.
  218.  
  219. Likewise for any snippets or other assets wanting to be edited.
  220.  
  221. Cloning & VCS Hooks
  222. ===================
  223.  
  224. Commenting out the original (with a slight marking in the comment
  225. `CLONED` ) would serve two purposes.
  226.  
  227. * For later `update diffs` to notify user of upstream package updates
  228. they may want to look at / merge in
  229.  
  230. * Don't pollute the bindings namespace with `disabled` keys
  231.  
  232. On update if an `asset` hasn't changed what so ever, comparing `pristine`
  233. version to the `latest` version then the commented out would not be
  234. updated.
  235.  
  236. If there has been an update then it will trigger merge notification.
  237.  
  238. QuickPanel hopping to Virtual Views of `assets`
  239. ===============================================
  240.  
  241. The use of virtual Views to present configuration `dialogs`, navigable
  242. via the QuickPanel and hiding UUID and other versioning metadata.
  243.  
  244. These snippet `forms` need not even be in XML.
  245.  
  246. ==============
  247. = conclusion =
  248. ==============
  249.  
  250. At the very least the `silent updates` must stop.
  251.  
  252. Personally I prefer update hooks for their simplicity or UUID +
  253. Virtual Views for real power. Cloning assets into the User folder as a
  254. means of dealing with version by itself seems like a lot of complexity
  255. for very little gain. Using version control renders it practically
  256. pointless.
  257.  
  258. UUIDs ensure any tidyup to file names for example are manageable.
  259.  
  260. bzr is the only version control system I can think of that has first
  261. class support for changing filenames and maintaining verson history.
  262. However it has a very checkered history with changes to the core repo
  263. format occuring extremely often
Add Comment
Please, Sign In to add comment