Commits

Anonymous committed 6e0a9c8

Fixed scope naming scheme and implemented jumping between inter document links on pressing enter.

Comments (0)

Files changed (3)

 ==========================
 
 * About
-  My shot on bringing Org-Mode {3} to Sublime Text 2 {4}. This project is still in very early development. Nobody knows what will come next :). This won't be a simple copycat of the original one. I want to "port" useful things in a way that works best for Sublime Text 2. So there may be things that aren't in either version or just behave more or less differently.
+  My shot on bringing Org-Mode {3} to Sublime Text 2 {4}. This project {1} is still in very early development. Nobody knows what will come next :). This won't be a simple copycat of the original one. I want to "port" useful things in a way that works best for Sublime Text 2. So there may be things that aren't in either version or just behave more or less differently.
 
 * Features
   Here's a list of all the features implemented so far:
     - Checkboxes
     - Checkbox summaries
     - External links
+    - Inter document links
   - Context sensitive actions
     - Toggle checkbox on pressing enter
     - Auto update of checkbox summary on toggle of checkboxes
     - Recalc number of children in checkbox summary on pressing enter
-    - External link opener on pressing enter
+    - External link opener on pressing enter (e.g. [[http://www.google.de]])
       (currently only working on OSX)
+    - Jumping between inter document links on pressing enter (e.g. {1})
 
 * Installation
 
 ** Theme additions for proper syntax highlighting
    See "Theme additions for proper syntax highlighting" under "Attachments" below for details.
 
-* Todo [1/9]
+* Todo [1/10]
   - [ ] External link opener on pressing enter [1/3]
     - [X] on OSX
     - [ ] on Linux
   - [X] Recalc number of children in checkbox summary on pressing enter.
   - [ ] When (un-)checking *all* checkboxes of siblings, toggle parent checkbox.
   - [ ] Either make highlight_code_remarks.py configurable thru view settings so that orgmode can control its regex patterns or fork/extend it to archive an equal goal.
-  - [ ] Inter-document links
-    - [ ] Highlighting
-    - [ ] Jump between similar numbers on pressing enter
   - [ ] Export into formatted text file
   - [ ] Automatic export after save into given format if mark found in org file.
   - [ ] Fix subsequent indents
   - [ ] Fix cursor position after filling checkbox summary on checkbox toggle
+  - [ ] Tab trigger "[]" which extends into "[ ] " and updates the summary
+  - [ ] Define special block/area in document where time logging can occur. If one changes the status (TODO, WORKING, DONE etc.) this will be written into the log. Ideas for format are welcome!
 
 * Known Issues
   - When creating an empty checkbox summary and hitting an checkbox below the cursor will be placed a little bit to the left. Seems like the selection is being rebuilt incorrectly due to the added chars for the summary.
    [code]
    { "keys": ["enter"], "command": "orgmode_toggle_checkbox", "context":
      [
-       { "key": "selector", "operator": "equal", "operand": "checkbox.orgmode" }
+       { "key": "selector", "operator": "equal", "operand": "orgmode.checkbox" }
      ]
    },
    { "keys": ["enter"], "command": "orgmode_recalc_checkbox_summary", "context":
      [
-       { "key": "selector", "operator": "equal", "operand": "summary.checkbox.orgmode" }
+       { "key": "selector", "operator": "equal", "operand":  "orgmode.checkbox.summary" }
      ]
    },
-   { "keys": ["enter"], "command": "orgmode_open_link", "context":
-     [
-       { "key": "selector", "operator": "equal", "operand": "link.orgmode" }
+   {  "keys": ["enter"], "command": "orgmode_open_link", "con text":
+      [
+         { "key": "selector", "operator": "equal", "operand":  "orgmode.link" }
+      ]
+   },
+   {  "keys": ["enter"], "command": "orgmode_cycle_internal_link", "context":
+      [
+         { "key": "selector", "operator": "equal", "operand":  "orgmode.link.internal" }
      ]
    }
    [/code]
        <key>name</key>
        <string>orgmode link</string>
        <key>scope</key>
-       <string>link.orgmode</string>
+       <string>orgmode.link</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
        <key>name</key>
        <string>orgmode page</string>
        <key>scope</key>
-       <string>page.orgmode</string>
+       <string>orgmode.page</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
        <key>name</key>
        <string>orgmode break</string>
        <key>scope</key>
-       <string>break.orgmode</string>
+       <string>orgmode.break</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
        <key>name</key>
        <string>orgmode headline</string>
        <key>scope</key>
-       <string>headline.orgmode</string>
+       <string>orgmode.headline</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
        <key>name</key>
        <string>orgmode tack</string>
        <key>scope</key>
-       <string>tack.orgmode</string>
+       <string>orgmode.tack</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
        <key>name</key>
        <string>orgmode checkbox</string>
        <key>scope</key>
-       <string>checkbox.orgmode</string>
+       <string>orgmode.checkbox</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
        <key>name</key>
        <string>orgmode checkbox summary</string>
        <key>scope</key>
-       <string>summary.checkbox.orgmode</string>
+       <string>orgmode.checkbox.summary</string>
        <key>settings</key>
        <dict>
          <key>foreground</key>
     def run(self, edit):
         view = self.view
         for sel in view.sel():
-            if 'link.orgmode' not in view.scope_name(sel.end()):
+            if 'orgmode.link' not in view.scope_name(sel.end()):
                 continue
             region = view.extract_scope(sel.end())
             content = view.substr(region)
                 sublime.error_message(stderr)
 
 
+class OrgmodeCycleInternalLinkCommand(sublime_plugin.TextCommand):
+
+    def run(self, edit):
+        view = self.view
+        sels = view.sel()
+        sel = sels[0]
+        if 'orgmode.link.internal' not in view.scope_name(sel.end()):
+            return
+        region = view.extract_scope(sel.end())
+        content = view.substr(region).strip()
+        found = self.view.find(content, region.end(), sublime.LITERAL)
+        if not found:  # Try wrapping around buffer.
+            found = self.view.find(content, 0, sublime.LITERAL)
+        same = region.a == found.a and region.b == found.b
+        if not found or same:
+            sublime.status_message('No sibling found for: %s' % content)
+            return
+        sels.clear()
+        sels.add(sublime.Region(found.begin()))
+        try:
+            import show_at_center_and_blink
+            view.run_command('show_at_center_and_blink')
+        except ImportError:
+            view.show_at_center(found)
+
+
 class AbstractCheckboxCommand(sublime_plugin.TextCommand):
 
     def __init__(self, *args, **kwargs):
         view = self.view
         backup = []
         for sel in view.sel():
-            if 'checkbox.orgmode' not in view.scope_name(sel.end()):
+            if 'orgmode.checkbox' not in view.scope_name(sel.end()):
                 continue
             backup.append(sel)
             child = view.extract_scope(sel.end())
         view = self.view
         backup = []
         for sel in view.sel():
-            if 'summary.checkbox.orgmode' not in view.scope_name(sel.end()):
+            if 'orgmode.checkbox.summary' not in view.scope_name(sel.end()):
                 continue
             backup.append(sel)
             summary = view.extract_scope(sel.end())

orgmode.tmLanguage

 	<array>
 		<dict>
 			<key>name</key>
-			<string>page.orgmode</string>
+			<string>orgmode.page</string>
 			<key>match</key>
 			<string>^(\-\-\-) .*\n?$</string>
 		</dict>
 		<dict>
 			<key>name</key>
-			<string>break.orgmode</string>
+			<string>orgmode.break</string>
 			<key>match</key>
 			<string>^(\~)+ .*\n?$</string>
 		</dict>
 		<dict>
 			<key>name</key>
-			<string>headline.orgmode</string>
+			<string>orgmode.headline</string>
 			<key>match</key>
 			<string>^\s*(\*)+ [^\[\]]*</string>
 		</dict>
 		<dict>
 			<key>name</key>
-			<string>tack.orgmode</string>
+			<string>orgmode.tack</string>
 			<key>match</key>
 			<string>^\s*(\-) </string>
 		</dict>
 		<dict>
 			<key>name</key>
-			<string>checkbox.orgmode</string>
+			<string>orgmode.checkbox</string>
 			<key>match</key>
 			<string>(\[[xX ]\])\s?</string>
 		</dict>
 		<dict>
 			<key>name</key>
-			<string>summary.checkbox.orgmode</string>
+			<string>orgmode.checkbox.summary</string>
 			<key>match</key>
 			<string>(\[\d*[/]\d*\])</string>
 		</dict>
 		<dict>
 			<key>name</key>
-			<string>link.orgmode</string>
+			<string>orgmode.link</string>
 			<key>match</key>
 			<string>\[\[(.+)\]\]</string>
 		</dict>
 		<dict>
+			<key>name</key>
+			<string>orgmode.link.internal</string>
+			<key>match</key>
+			<string>\{(\d+)\}</string>
+		</dict>
+		<dict>
 			<key>contentName</key>
 			<string>text source</string>
 			<key>begin</key>