Skip to content
This repository
Browse code

Merge remote-tracking branch 'rolandwalker/byte-compiler-3'

Fix: reorder defuns to quieten byte-compiler

Conflicts:
	yasnippet.el
  • Loading branch information...
commit d5865b1092fd24099f4afedf0e5016fe9da86b5f 2 parents 5520088 + b7fe4c1
João Távora authored

Showing 1 changed file with 87 additions and 81 deletions. Show diff stats Hide diff stats

  1. 168  yasnippet.el
168  yasnippet.el
@@ -1613,11 +1613,98 @@ Optional PROMPT sets the prompt to use."
1613 1613
   (first choices))
1614 1614
 
1615 1615
 
  1616
+;;; Defining snippets
  1617
+;; This consists of creating and registering `yas--template' objects in the
  1618
+;; correct tables.
  1619
+;;
  1620
+
  1621
+(defun yas-define-snippets-1 (snippet snippet-table)
  1622
+  "Helper for `yas-define-snippets'."
  1623
+  ;; X) Calculate some more defaults on the values returned by
  1624
+  ;; `yas--parse-template'.
  1625
+  ;;
  1626
+  (let* ((file (seventh snippet))
  1627
+         (key (car snippet))
  1628
+         (name (or (third snippet)
  1629
+                   (and file
  1630
+                        (file-name-directory file))))
  1631
+         (condition (fourth snippet))
  1632
+         (group (fifth snippet))
  1633
+         (keybinding (yas--read-keybinding (eighth snippet)))
  1634
+         (uuid (or (ninth snippet)
  1635
+                  name))
  1636
+         (template (or (gethash uuid (yas--table-uuidhash snippet-table))
  1637
+                       (yas--make-blank-template))))
  1638
+    ;; X) populate the template object
  1639
+    ;;
  1640
+    (yas--populate-template template
  1641
+                           :table       snippet-table
  1642
+                           :key         key
  1643
+                           :content     (second snippet)
  1644
+                           :name        (or name key)
  1645
+                           :group       group
  1646
+                           :condition   condition
  1647
+                           :expand-env  (sixth snippet)
  1648
+                           :file        (seventh snippet)
  1649
+                           :keybinding  keybinding
  1650
+                           :uuid         uuid)
  1651
+    ;; X) Update this template in the appropriate table. This step
  1652
+    ;;    also will take care of adding the key indicators in the
  1653
+    ;;    templates menu entry, if any
  1654
+    ;;
  1655
+    (yas--update-template snippet-table template)
  1656
+    ;; X) Return the template
  1657
+    ;;
  1658
+    ;;
  1659
+    template))
  1660
+
  1661
+(defun yas-define-snippets (mode snippets)
  1662
+  "Define SNIPPETS for MODE.
  1663
+
  1664
+SNIPPETS is a list of snippet definitions, each taking the
  1665
+following form
  1666
+
  1667
+ (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV FILE KEYBINDING UUID)
  1668
+
  1669
+Within these, only KEY and TEMPLATE are actually mandatory.
  1670
+
  1671
+TEMPLATE might be a lisp form or a string, depending on whether
  1672
+this is a snippet or a snippet-command.
  1673
+
  1674
+CONDITION, EXPAND-ENV and KEYBINDING are lisp forms, they have
  1675
+been `yas--read-lisp'-ed and will eventually be
  1676
+`yas--eval-lisp'-ed.
  1677
+
  1678
+The remaining elements are strings.
  1679
+
  1680
+FILE is probably of very little use if you're programatically
  1681
+defining snippets.
  1682
+
  1683
+UUID is the snippets \"unique-id\". Loading a second snippet file
  1684
+with the same uuid replaced the previous snippet.
  1685
+
  1686
+You can use `yas--parse-template' to return such lists based on
  1687
+the current buffers contents."
  1688
+  (let ((snippet-table (yas--table-get-create mode))
  1689
+        (template nil))
  1690
+    (dolist (snippet snippets)
  1691
+      (setq template (yas-define-snippets-1 snippet
  1692
+                                            snippet-table)))
  1693
+    template))
  1694
+
  1695
+
1616 1696
 ;;; Loading snippets from files
1617 1697
 
1618 1698
 (defun yas--load-yas-setup-file (file)
1619 1699
   (load file 'noerror))
1620 1700
 
  1701
+(defun yas--define-parents (mode parents)
  1702
+  "Add PARENTS to the list of MODE's parents."
  1703
+  (puthash mode (remove-duplicates
  1704
+                 (append parents
  1705
+                         (gethash mode yas--parents)))
  1706
+           yas--parents))
  1707
+
1621 1708
 (defun yas-load-directory (top-level-dir &optional use-jit)
1622 1709
   "Load snippets in directory hierarchy TOP-LEVEL-DIR.
1623 1710
 
@@ -1867,87 +1954,6 @@ This works by stubbing a few functions, then calling
1867 1954
                    yas--version
1868 1955
                    ") -- pluskid <pluskid@gmail.com>/joaotavora <joaotavora@gmail.com>")))
1869 1956
 
1870  
-(defun yas--define-parents (mode parents)
1871  
-  "Add PARENTS to the list of MODE's parents."
1872  
-  (puthash mode (remove-duplicates
1873  
-                 (append parents
1874  
-                         (gethash mode yas--parents)))
1875  
-           yas--parents))
1876  
-
1877  
-(defun yas-define-snippets (mode snippets)
1878  
-  "Define SNIPPETS for MODE.
1879  
-
1880  
-SNIPPETS is a list of snippet definitions, each taking the
1881  
-following form
1882  
-
1883  
- (KEY TEMPLATE NAME CONDITION GROUP EXPAND-ENV FILE KEYBINDING UUID)
1884  
-
1885  
-Within these, only KEY and TEMPLATE are actually mandatory.
1886  
-
1887  
-TEMPLATE might be a lisp form or a string, depending on whether
1888  
-this is a snippet or a snippet-command.
1889  
-
1890  
-CONDITION, EXPAND-ENV and KEYBINDING are lisp forms, they have
1891  
-been `yas--read-lisp'-ed and will eventually be
1892  
-`yas--eval-lisp'-ed.
1893  
-
1894  
-The remaining elements are strings.
1895  
-
1896  
-FILE is probably of very little use if you're programatically
1897  
-defining snippets.
1898  
-
1899  
-UUID is the snippets \"unique-id\". Loading a second snippet file
1900  
-with the same uuid replaced the previous snippet.
1901  
-
1902  
-You can use `yas--parse-template' to return such lists based on
1903  
-the current buffers contents."
1904  
-  (let ((snippet-table (yas--table-get-create mode))
1905  
-        (template nil))
1906  
-    (dolist (snippet snippets)
1907  
-      (setq template (yas-define-snippets-1 snippet
1908  
-                                            snippet-table)))
1909  
-    template))
1910  
-
1911  
-(defun yas-define-snippets-1 (snippet snippet-table)
1912  
-  "Helper for `yas-define-snippets'."
1913  
-  ;; X) Calculate some more defaults on the values returned by
1914  
-  ;; `yas--parse-template'.
1915  
-  ;;
1916  
-  (let* ((file (seventh snippet))
1917  
-         (key (car snippet))
1918  
-         (name (or (third snippet)
1919  
-                   (and file
1920  
-                        (file-name-directory file))))
1921  
-         (condition (fourth snippet))
1922  
-         (group (fifth snippet))
1923  
-         (keybinding (yas--read-keybinding (eighth snippet)))
1924  
-         (uuid (or (ninth snippet)
1925  
-                  name))
1926  
-         (template (or (gethash uuid (yas--table-uuidhash snippet-table))
1927  
-                       (yas--make-blank-template))))
1928  
-    ;; X) populate the template object
1929  
-    ;;
1930  
-    (yas--populate-template template
1931  
-                           :table       snippet-table
1932  
-                           :key         key
1933  
-                           :content     (second snippet)
1934  
-                           :name        (or name key)
1935  
-                           :group       group
1936  
-                           :condition   condition
1937  
-                           :expand-env  (sixth snippet)
1938  
-                           :file        (seventh snippet)
1939  
-                           :keybinding  keybinding
1940  
-                           :uuid         uuid)
1941  
-    ;; X) Update this template in the appropriate table. This step
1942  
-    ;;    also will take care of adding the key indicators in the
1943  
-    ;;    templates menu entry, if any
1944  
-    ;;
1945  
-    (yas--update-template snippet-table template)
1946  
-    ;; X) Return the template
1947  
-    ;;
1948  
-    ;;
1949  
-    template))
1950  
-
1951 1957
 
1952 1958
 ;;; Apropos snippet menu:
1953 1959
 ;;

0 notes on commit d5865b1

Please sign in to comment.
Something went wrong with that request. Please try again.