From 90c4e54927f62373733b774e9fa33330fffbb082 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Thu, 31 Oct 2019 16:04:29 +0100 Subject: [PATCH] update yasnippets --- bba.org | 2 +- .../snippets/sql-interactive-mode/busy-hours | 21 + .../sql-interactive-mode/check_rle_overridden | 0 .../sql-interactive-mode/config-changes | 21 + .../sql-interactive-mode/current_epoch | 0 .../snippets/sql-interactive-mode/errors | 0 .../external_table_details | 0 .../sql-interactive-mode/format_numbers | 8 + .../sql-interactive-mode/get-partitions | 0 .../sql-interactive-mode/get-projections | 0 .../snippets/sql-interactive-mode/grants | 0 .../last-statement-timing | 0 .../sql-interactive-mode/licence-history | 16 + .../sql-interactive-mode/list-backups | 0 .../list-tables-row-count-size | 0 .../snippets/sql-interactive-mode/nodes | 0 .../snippets/sql-interactive-mode/pool_queues | 0 .../snippets/sql-interactive-mode/pset_footer | 7 + .../query-acquisition-queue | 17 + .../sql-interactive-mode/query-event-issues | 17 + .../query-long-acquisitions | 17 + .../sql-interactive-mode/query-requests | 14 + .../snippets/sql-interactive-mode/query-times | 0 .../sql-interactive-mode/rebalance_status | 0 .../sql-interactive-mode/resource-pool-move | 0 .../sql-interactive-mode/resource_pools | 0 .../snippets/sql-interactive-mode/resources | 0 .../snippets/sql-interactive-mode/sessions | 0 .../sql-interactive-mode/storage-containers | 0 .../sql-interactive-mode/storage-locations | 0 .../sql-interactive-mode/user_sessions | 0 .../sql-interactive-mode/vertica_users | 0 .../snippets/sql-mode/.yas-parents | 0 .../vertica-snippets-autoloads.el | 15 +- .../vertica-snippets-pkg.el | 2 +- .../vertica-snippets.el | 0 elpa/yasnippet-20181015.1212/yasnippet-pkg.el | 2 - .../yasnippet-autoloads.el | 11 +- elpa/yasnippet-20191030.1331/yasnippet-pkg.el | 2 + .../yasnippet.el | 572 +++++++++++------- 40 files changed, 501 insertions(+), 243 deletions(-) create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/busy-hours rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/check_rle_overridden (100%) create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/config-changes rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/current_epoch (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/errors (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/external_table_details (100%) create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/format_numbers rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/get-partitions (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/get-projections (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/grants (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/last-statement-timing (100%) create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/licence-history rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/list-backups (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/list-tables-row-count-size (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/nodes (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/pool_queues (100%) create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/pset_footer create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-acquisition-queue create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-event-issues create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-long-acquisitions create mode 100644 elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-requests rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/query-times (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/rebalance_status (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/resource-pool-move (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/resource_pools (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/resources (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/sessions (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/storage-containers (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/storage-locations (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/user_sessions (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-interactive-mode/vertica_users (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/snippets/sql-mode/.yas-parents (100%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/vertica-snippets-autoloads.el (61%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/vertica-snippets-pkg.el (83%) rename elpa/{vertica-snippets-20181212.1627 => vertica-snippets-20191007.1546}/vertica-snippets.el (100%) delete mode 100644 elpa/yasnippet-20181015.1212/yasnippet-pkg.el rename elpa/{yasnippet-20181015.1212 => yasnippet-20191030.1331}/yasnippet-autoloads.el (81%) create mode 100644 elpa/yasnippet-20191030.1331/yasnippet-pkg.el rename elpa/{yasnippet-20181015.1212 => yasnippet-20191030.1331}/yasnippet.el (91%) diff --git a/bba.org b/bba.org index 3c41540d..8a033764 100644 --- a/bba.org +++ b/bba.org @@ -541,7 +541,7 @@ snippets for =aws cli= are awesome! #+BEGIN_SRC emacs-lisp :tangle yes (add-to-list 'load-path - "~/.emacs.d/elpa/yasnippet-20181015.1212") + "~/.emacs.d/elpa/yasnippet-20191030.1331") (require 'yasnippet) (if (equal "work" (getenv "SYSENV")) diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/busy-hours b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/busy-hours new file mode 100644 index 00000000..e77634ad --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/busy-hours @@ -0,0 +1,21 @@ +# -*- mode: snippet -*- +# name: busy-hours +# key: bh_ +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# https://www.vertica.com/blog/find-the-busiest-hour-in-the-day-for-i-o/ +# -- + +SELECT * + FROM (SELECT "HOUR", "Total IO (GB)", "Read IO (GB)", "Write IO (GB)" + FROM (SELECT MIN(TRUNC(start_time)) start_time, + DATE_TRUNC('hour', start_time) as "HOUR", + (SUM(read_kbytes_per_sec) + SUM(written_kbytes_per_sec)) * 60/1024/1024 as "Total IO (GB)", + SUM(read_kbytes_per_sec) * 60/1024/1024 as "Read IO (GB)", + SUM(written_kbytes_per_sec) * 60/1024/1024 as "Write IO (GB)" + FROM v_monitor.io_usage + GROUP BY 2) foo + WHERE start_time >= TRUNC(SYSDATE) - 5 -- LAST 5 DAYS! + LIMIT 1 OVER (PARTITION BY start_time ORDER BY start_time, "Total IO (GB)" DESC)) foo2 + ORDER BY "HOUR" DESC;$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/check_rle_overridden b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/check_rle_overridden similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/check_rle_overridden rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/check_rle_overridden diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/config-changes b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/config-changes new file mode 100644 index 00000000..77740f8a --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/config-changes @@ -0,0 +1,21 @@ +# -*- mode: snippet -*- +# name: config-changes +# key: config-changes +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# https://www.vertica.com/blog/generate-ddl-for-changed-configuration-parameters/ +# -- + SELECT DISTINCT ddl + FROM (SELECT CASE + WHEN current_level = 'DATABASE' OR (current_level = 'DEFAULT' AND INSTR(allowed_levels, 'DATABASE') > 0) THEN + 'SELECT set_config_parameter(''' || parameter || ''', ''' || value || ''');' + WHEN current_level = 'NODE' THEN + 'ALTER NODE ' || configuration_changes.node_name || ' SET ' || parameter || ' = ''' || value || ''';' + END AS ddl + FROM configuration_changes + JOIN configuration_parameters + ON parameter = parameter_name + WHERE allowed_levels <> 'SESSION' + LIMIT 1 OVER (PARTITION BY configuration_changes.node_name, parameter ORDER BY event_timestamp DESC)) foo + ORDER BY 1;$0 diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/current_epoch b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/current_epoch similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/current_epoch rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/current_epoch diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/errors b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/errors similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/errors rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/errors diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/external_table_details b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/external_table_details similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/external_table_details rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/external_table_details diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/format_numbers b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/format_numbers new file mode 100644 index 00000000..302d2329 --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/format_numbers @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: format_numbers +# key: _fn_ +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# -- +TO_CHAR( $0, '999g999g999g999') AS \ No newline at end of file diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/get-partitions b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/get-partitions similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/get-partitions rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/get-partitions diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/get-projections b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/get-projections similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/get-projections rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/get-projections diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/grants b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/grants similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/grants rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/grants diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/last-statement-timing b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/last-statement-timing similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/last-statement-timing rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/last-statement-timing diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/licence-history b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/licence-history new file mode 100644 index 00000000..9e5272ec --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/licence-history @@ -0,0 +1,16 @@ +# -*- mode: snippet -*- +# name: licence-history +# key: lic_history +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# https://www.vertica.com/blog/track-license-usage-over-time/ +# -- + SELECT * FROM ( + SELECT TRUNC(audit_start_timestamp)::DATE the_date, usage_percent * 100 AS usage_percent + FROM license_audits + WHERE audited_data = 'Total' + LIMIT 1 OVER (PARTITION BY TRUNC(audit_start_timestamp) ORDER BY audit_start_timestamp DESC) + ) foo + ORDER BY 1 DESC + LIMIT 7;$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/list-backups b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/list-backups similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/list-backups rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/list-backups diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/list-tables-row-count-size b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/list-tables-row-count-size similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/list-tables-row-count-size rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/list-tables-row-count-size diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/nodes b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/nodes similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/nodes rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/nodes diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/pool_queues b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/pool_queues similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/pool_queues rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/pool_queues diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/pset_footer b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/pset_footer new file mode 100644 index 00000000..d66c50d7 --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/pset_footer @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: pset_footer +# key: footer_ +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# -- +\pset footer 0$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-acquisition-queue b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-acquisition-queue new file mode 100644 index 00000000..e0d46a38 --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-acquisition-queue @@ -0,0 +1,17 @@ +# -*- mode: snippet -*- +# name: query-acquisition-queue +# key: query-acq-queue +# group: vertica +# documentation: https://www.vertica.com/blog/calculate-request-queue-length-quick-tip/?utm_campaign=00164962 +# condition: (if (string-equal sql-product 'vertica)t) +# -- +SELECT node_name, + request_type, + transaction_id, + statement_id, + pool_name, + (acquisition_timestamp - queue_entry_timestamp) request_queue_length +FROM v_monitor.resource_acquisitions +WHERE pool_name = 'general' +ORDER BY (acquisition_timestamp - queue_entry_timestamp) DESC +LIMIT 1;$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-event-issues b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-event-issues new file mode 100644 index 00000000..1870df6d --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-event-issues @@ -0,0 +1,17 @@ +# -*- mode: snippet -*- +# name: query-event-issues +# key: qei_ +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# https://www.vertica.com/blog/find-and-fix-issues-from-vertica-query-events/ +# -- +SELECT event_description, + suggested_action, + COUNT(*) + FROM query_events + WHERE suggested_action IS NOT NULL + AND suggested_action <> 'Informational; No user action is necessary' + GROUP BY 1, + 2 + ORDER BY 3 DESC;$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-long-acquisitions b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-long-acquisitions new file mode 100644 index 00000000..6d828c00 --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-long-acquisitions @@ -0,0 +1,17 @@ +# -*- mode: snippet -*- +# name: query-long-acquisitions +# key: query-long-acq +# group: vertica +# documentation: https://www.vertica.com/blog/calculate-request-queue-length-quick-tip/?utm_campaign=00164962 +# condition: (if (string-equal sql-product 'vertica)t) +# -- +SELECT node_name, + request_type, + transaction_id, + statement_id, + pool_name, + (acquisition_timestamp - queue_entry_timestamp) request_queue_length +FROM v_monitor.resource_acquisitions +WHERE pool_name = 'general' +AND (acquisition_timestamp - queue_entry_timestamp) > '1 second' +ORDER BY (acquisition_timestamp - queue_entry_timestamp) DESC;$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-requests b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-requests new file mode 100644 index 00000000..6c54a2d2 --- /dev/null +++ b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-requests @@ -0,0 +1,14 @@ +# -*- mode: snippet -*- +# name: query-requests +# key: qr_ +# group: vertica +# condition: (if (string-equal sql-product 'vertica)t) +# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't)) +# -- +SELECT request + FROM v_monitor.query_requests + WHERE user_name = '$1' + AND request_type = '${2:$$(yas-choose-value '("QUERY" "SHOW" "SET" "DDL" "TRUNCATE" "TRANSACTION" "LOAD"))}' + AND start_timestamp::DATE = '${3:`(insert (format-time-string "%Y-%m-%d"))`}' + AND request_label LIKE '$4' + ORDER BY start_timestamp ASC;$0 \ No newline at end of file diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/query-times b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-times similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/query-times rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/query-times diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/rebalance_status b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/rebalance_status similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/rebalance_status rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/rebalance_status diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/resource-pool-move b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/resource-pool-move similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/resource-pool-move rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/resource-pool-move diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/resource_pools b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/resource_pools similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/resource_pools rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/resource_pools diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/resources b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/resources similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/resources rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/resources diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/sessions b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/sessions similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/sessions rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/sessions diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/storage-containers b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/storage-containers similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/storage-containers rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/storage-containers diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/storage-locations b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/storage-locations similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/storage-locations rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/storage-locations diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/user_sessions b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/user_sessions similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/user_sessions rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/user_sessions diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/vertica_users b/elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/vertica_users similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-interactive-mode/vertica_users rename to elpa/vertica-snippets-20191007.1546/snippets/sql-interactive-mode/vertica_users diff --git a/elpa/vertica-snippets-20181212.1627/snippets/sql-mode/.yas-parents b/elpa/vertica-snippets-20191007.1546/snippets/sql-mode/.yas-parents similarity index 100% rename from elpa/vertica-snippets-20181212.1627/snippets/sql-mode/.yas-parents rename to elpa/vertica-snippets-20191007.1546/snippets/sql-mode/.yas-parents diff --git a/elpa/vertica-snippets-20181212.1627/vertica-snippets-autoloads.el b/elpa/vertica-snippets-20191007.1546/vertica-snippets-autoloads.el similarity index 61% rename from elpa/vertica-snippets-20181212.1627/vertica-snippets-autoloads.el rename to elpa/vertica-snippets-20191007.1546/vertica-snippets-autoloads.el index 756a1bef..20d0609e 100644 --- a/elpa/vertica-snippets-20181212.1627/vertica-snippets-autoloads.el +++ b/elpa/vertica-snippets-20191007.1546/vertica-snippets-autoloads.el @@ -1,13 +1,10 @@ ;;; vertica-snippets-autoloads.el --- automatically extracted autoloads ;; ;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) -;;;### (autoloads nil "vertica-snippets" "vertica-snippets.el" (0 -;;;;;; 0 0 0)) +;;;### (autoloads nil "vertica-snippets" "vertica-snippets.el" (23994 +;;;;;; 46376 342293 671000)) ;;; Generated autoloads from vertica-snippets.el (autoload 'vertica-snippets-initialize "vertica-snippets" "\ @@ -17,11 +14,10 @@ Add snippet dir to yas-snippet-dirs and load it. (eval-after-load 'yasnippet '(vertica-snippets-initialize)) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "vertica-snippets" '("vertica-snippets-dir"))) - ;;;*** -;;;### (autoloads nil nil ("vertica-snippets-pkg.el") (0 0 0 0)) +;;;### (autoloads nil nil ("vertica-snippets-pkg.el") (23994 46376 +;;;;;; 343407 998000)) ;;;*** @@ -29,6 +25,5 @@ Add snippet dir to yas-snippet-dirs and load it. ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 ;; End: ;;; vertica-snippets-autoloads.el ends here diff --git a/elpa/vertica-snippets-20181212.1627/vertica-snippets-pkg.el b/elpa/vertica-snippets-20191007.1546/vertica-snippets-pkg.el similarity index 83% rename from elpa/vertica-snippets-20181212.1627/vertica-snippets-pkg.el rename to elpa/vertica-snippets-20191007.1546/vertica-snippets-pkg.el index 58ad9b43..2411512a 100644 --- a/elpa/vertica-snippets-20181212.1627/vertica-snippets-pkg.el +++ b/elpa/vertica-snippets-20191007.1546/vertica-snippets-pkg.el @@ -1,4 +1,4 @@ -(define-package "vertica-snippets" "20181212.1627" "Yasnippets for Vertica" +(define-package "vertica-snippets" "20191007.1546" "Yasnippets for Vertica" '((yasnippet "0.6.1")) :keywords '("convenience" "snippets") diff --git a/elpa/vertica-snippets-20181212.1627/vertica-snippets.el b/elpa/vertica-snippets-20191007.1546/vertica-snippets.el similarity index 100% rename from elpa/vertica-snippets-20181212.1627/vertica-snippets.el rename to elpa/vertica-snippets-20191007.1546/vertica-snippets.el diff --git a/elpa/yasnippet-20181015.1212/yasnippet-pkg.el b/elpa/yasnippet-20181015.1212/yasnippet-pkg.el deleted file mode 100644 index 47a293bd..00000000 --- a/elpa/yasnippet-20181015.1212/yasnippet-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "yasnippet" "20181015.1212" "Yet another snippet extension for Emacs." '((cl-lib "0.5")) :commit "1d96da2e08664c31ff7f6f7441da1f4fa5680b1f" :keywords '("convenience" "emulation") :maintainer '("Noam Postavsky" . "npostavs@gmail.com") :url "http://github.com/joaotavora/yasnippet") diff --git a/elpa/yasnippet-20181015.1212/yasnippet-autoloads.el b/elpa/yasnippet-20191030.1331/yasnippet-autoloads.el similarity index 81% rename from elpa/yasnippet-20181015.1212/yasnippet-autoloads.el rename to elpa/yasnippet-20191030.1331/yasnippet-autoloads.el index 2659fe88..c6002f36 100644 --- a/elpa/yasnippet-20181015.1212/yasnippet-autoloads.el +++ b/elpa/yasnippet-20191030.1331/yasnippet-autoloads.el @@ -1,12 +1,10 @@ ;;; yasnippet-autoloads.el --- automatically extracted autoloads ;; ;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - +(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) -;;;### (autoloads nil "yasnippet" "yasnippet.el" (0 0 0 0)) +;;;### (autoloads nil "yasnippet" "yasnippet.el" (23994 42571 235335 +;;;;;; 668000)) ;;; Generated autoloads from yasnippet.el (autoload 'yas-minor-mode "yasnippet" "\ @@ -48,14 +46,11 @@ See `yas-minor-mode' for more information on Yas minor mode. \(fn &optional ARG)" t nil) (autoload 'snippet-mode "yasnippet" "A mode for editing yasnippets" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "yasnippet" '("yas" "help-snippet-def" "snippet-mode-map"))) - ;;;*** ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 ;; End: ;;; yasnippet-autoloads.el ends here diff --git a/elpa/yasnippet-20191030.1331/yasnippet-pkg.el b/elpa/yasnippet-20191030.1331/yasnippet-pkg.el new file mode 100644 index 00000000..590ce882 --- /dev/null +++ b/elpa/yasnippet-20191030.1331/yasnippet-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "yasnippet" "20191030.1331" "Yet another snippet extension for Emacs" '((cl-lib "0.5")) :commit "1bee3a33c77d1a61c331461750e01c4f6fa85417" :keywords '("convenience" "emulation") :maintainer '("Noam Postavsky" . "npostavs@gmail.com") :url "http://github.com/joaotavora/yasnippet") diff --git a/elpa/yasnippet-20181015.1212/yasnippet.el b/elpa/yasnippet-20191030.1331/yasnippet.el similarity index 91% rename from elpa/yasnippet-20181015.1212/yasnippet.el rename to elpa/yasnippet-20191030.1331/yasnippet.el index 58ff8fd1..626e6561 100644 --- a/elpa/yasnippet-20181015.1212/yasnippet.el +++ b/elpa/yasnippet-20191030.1331/yasnippet.el @@ -1,12 +1,12 @@ -;;; yasnippet.el --- Yet another snippet extension for Emacs. +;;; yasnippet.el --- Yet another snippet extension for Emacs -;; Copyright (C) 2008-2018 Free Software Foundation, Inc. +;; Copyright (C) 2008-2019 Free Software Foundation, Inc. ;; Authors: pluskid , ;; João Távora , ;; Noam Postavsky ;; Maintainer: Noam Postavsky ;; Version: 0.13.0 -;; Package-Version: 20181015.1212 +;; Package-Version: 20191030.1331 ;; X-URL: http://github.com/joaotavora/yasnippet ;; Keywords: convenience, emulation ;; URL: http://github.com/joaotavora/yasnippet @@ -382,8 +382,7 @@ the trigger key itself." (defcustom yas-alias-to-yas/prefix-p t "If non-nil make aliases for the old style yas/ prefixed symbols. It must be set to nil before loading yasnippet to take effect." - :type 'boolean - :group 'yasnippet) + :type 'boolean) ;; Only two faces, and one of them shouldn't even be used... ;; @@ -414,15 +413,25 @@ This can be used as a key definition in keymaps to bind a key to `yas-clear-field' only when at the beginning of an unmodified snippet field.") -(defvar yas-keymap (let ((map (make-sparse-keymap))) - (define-key map [(tab)] 'yas-next-field-or-maybe-expand) - (define-key map (kbd "TAB") 'yas-next-field-or-maybe-expand) - (define-key map [(shift tab)] 'yas-prev-field) - (define-key map [backtab] 'yas-prev-field) - (define-key map (kbd "C-g") 'yas-abort-snippet) - (define-key map (kbd "C-d") yas-maybe-skip-and-clear-field) - (define-key map (kbd "DEL") yas-maybe-clear-field) - map) +(defun yas-filtered-definition (def) + "Return a condition key definition. +The condition will respect the value of `yas-keymap-disable-hook'." + `(menu-item "" ,def + :filter ,(lambda (cmd) (unless (run-hook-with-args-until-success + 'yas-keymap-disable-hook) + cmd)))) + +(defvar yas-keymap + (let ((map (make-sparse-keymap))) + (define-key map [(tab)] (yas-filtered-definition 'yas-next-field-or-maybe-expand)) + (define-key map (kbd "TAB") (yas-filtered-definition 'yas-next-field-or-maybe-expand)) + (define-key map [(shift tab)] (yas-filtered-definition 'yas-prev-field)) + (define-key map [backtab] (yas-filtered-definition 'yas-prev-field)) + (define-key map (kbd "C-g") (yas-filtered-definition 'yas-abort-snippet)) + ;; Yes, filters can be chained! + (define-key map (kbd "C-d") (yas-filtered-definition yas-maybe-skip-and-clear-field)) + (define-key map (kbd "DEL") (yas-filtered-definition yas-maybe-clear-field)) + map) "The active keymap while a snippet expansion is in progress.") (defvar yas-key-syntaxes (list #'yas-try-key-from-whitespace @@ -482,10 +491,8 @@ Attention: These hooks are not run when exiting nested/stacked snippet expansion "Hooks to run just before expanding a snippet.") (defconst yas-not-string-or-comment-condition - '(if (and (let ((ppss (syntax-ppss))) - (or (nth 3 ppss) (nth 4 ppss))) - (memq this-command '(yas-expand yas-expand-from-trigger-key - yas-expand-from-keymap))) + '(if (let ((ppss (syntax-ppss))) + (or (nth 3 ppss) (nth 4 ppss))) '(require-snippet-condition . force-in-comment) t) "Disables snippet expansion in strings and comments. @@ -548,12 +555,28 @@ conditions. (const :tag "Disable all snippet expansion" nil) sexp)) +(defcustom yas-keymap-disable-hook nil + "The `yas-keymap' bindings are disabled if any function in this list returns non-nil. +This is useful to control whether snippet navigation bindings +override bindings from other packages (e.g., `company-mode')." + :type 'hook) + (defcustom yas-overlay-priority 100 "Priority to use for yasnippets overlays. This is useful to control whether snippet navigation bindings -override bindings from other packages (e.g., `company-mode')." +override `keymap' overlay property bindings from other packages." :type 'integer) +(defcustom yas-inhibit-overlay-modification-protection nil + "If nil, changing text outside the active field aborts the snippet. +This protection is intended to prevent yasnippet from ending up +in an inconsistent state. However, some packages (e.g., the +company completion package) may trigger this protection when it +is not needed. In that case, setting this variable to non-nil +can be useful." + ;; See also `yas--on-protection-overlay-modification'. + :type 'boolean) + ;;; Internal variables @@ -767,12 +790,12 @@ expanded.") ["About" yas-about :help "Display some information about YASnippet"])) +(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.9.1") (defvar yas--extra-modes nil "An internal list of modes for which to also lookup snippets. This variable probably makes more sense as buffer-local, so ensure your use `make-local-variable' when you set it.") -(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.9.1") (defvar yas--tables (make-hash-table) "A hash table of mode symbols to `yas--table' objects.") @@ -919,9 +942,12 @@ activate snippets associated with that mode." (remove mode yas--extra-modes))) +(defun yas-temp-buffer-p (&optional buffer) + (eq (aref (buffer-name buffer) 0) ?\s)) + (define-obsolete-variable-alias 'yas-dont-activate 'yas-dont-activate-functions "0.9.2") -(defvar yas-dont-activate-functions (list #'minibufferp) +(defvar yas-dont-activate-functions (list #'minibufferp #'yas-temp-buffer-p) "Special hook to control which buffers `yas-global-mode' affects. Functions are called with no argument, and should return non-nil to prevent `yas-global-mode' from enabling yasnippet in this buffer. @@ -1374,6 +1400,9 @@ conditions to filter out potential expansions." (push (cons name template) acc)) namehash)) (yas--table-hash table)) + (maphash #'(lambda (uuid template) + (push (cons uuid template) acc)) + (yas--table-uuidhash table)) (yas--filter-templates-by-condition acc)))) (defun yas--templates-for-key-at-point () @@ -1666,10 +1695,8 @@ Here's a list of currently recognized directives: (let ((where (if (region-active-p) (cons (region-beginning) (region-end)) (cons (point) (point))))) - (yas-expand-snippet (yas--template-content yas--current-template) - (car where) - (cdr where) - (yas--template-expand-env yas--current-template))))))) + (yas-expand-snippet yas--current-template + (car where) (cdr where))))))) (defun yas--key-from-desc (text) "Return a yasnippet key from a description string TEXT." @@ -2346,6 +2373,10 @@ object satisfying `yas--field-p' to restrict the expansion to." (yas--fallback)))) (defun yas--maybe-expand-from-keymap-filter (cmd) + "Check whether a snippet may be expanded. +If there are expandable snippets, return CMD (this is useful for +conditional keybindings) or the list of expandable snippet +template objects if CMD is nil (this is useful as a more general predicate)." (let* ((yas--condition-cache-timestamp (current-time)) (vec (cl-subseq (this-command-keys-vector) (if current-prefix-arg @@ -2370,14 +2401,12 @@ object satisfying `yas--field-p' to restrict the expansion to." Prompt the user if TEMPLATES has more than one element, else expand immediately. Common gateway for `yas-expand-from-trigger-key' and `yas-expand-from-keymap'." - (let ((yas--current-template (or (and (cl-rest templates) ;; more than one - (yas--prompt-for-template (mapcar #'cdr templates))) - (cdar templates)))) + (let ((yas--current-template + (or (and (cl-rest templates) ;; more than one + (yas--prompt-for-template (mapcar #'cdr templates))) + (cdar templates)))) (when yas--current-template - (yas-expand-snippet (yas--template-content yas--current-template) - start - end - (yas--template-expand-env yas--current-template))))) + (yas-expand-snippet yas--current-template start end)))) ;; Apropos the trigger key and the fallback binding: ;; @@ -2522,10 +2551,7 @@ by condition." (cons (region-beginning) (region-end)) (cons (point) (point))))) (if yas--current-template - (yas-expand-snippet (yas--template-content yas--current-template) - (car where) - (cdr where) - (yas--template-expand-env yas--current-template)) + (yas-expand-snippet yas--current-template (car where) (cdr where)) (yas--message 1 "No snippets can be inserted here!")))) (defun yas-visit-snippet-file () @@ -2813,17 +2839,17 @@ DEBUG is for debugging the YASnippet engine itself." :name (nth 2 parsed) :expand-env (nth 5 parsed))))) (cond (yas--current-template - (let ((buffer-name (format "*testing snippet: %s*" (yas--template-name yas--current-template)))) + (let ((buffer-name + (format "*testing snippet: %s*" + (yas--template-name yas--current-template)))) (kill-buffer (get-buffer-create buffer-name)) (switch-to-buffer (get-buffer-create buffer-name)) (setq buffer-undo-list nil) (condition-case nil (funcall test-mode) (error nil)) (yas-minor-mode 1) (setq buffer-read-only nil) - (yas-expand-snippet (yas--template-content yas--current-template) - (point-min) - (point-max) - (yas--template-expand-env yas--current-template)) + (yas-expand-snippet yas--current-template + (point-min) (point-max)) (when (and debug (require 'yasnippet-debug nil t)) (yas-debug-snippets "*YASnippet trace*" 'snippet-navigation) @@ -3016,8 +3042,13 @@ snippet field. The arguments are the same as `completing-read'. (defun yas--auto-next () "Helper for `yas-auto-next'." - (remove-hook 'post-command-hook #'yas--auto-next t) - (yas-next-field)) + (cl-loop + do (progn (remove-hook 'post-command-hook #'yas--auto-next t) + (yas-next-field)) + ;; The transform in the next field may have requested auto-next as + ;; well. Call it ourselves, since the command loop itself won't + ;; recheck the value of post-command-hook while running it. + while (memq #'yas--auto-next post-command-hook))) (defmacro yas-auto-next (&rest body) "Automatically advance to next field after eval'ing BODY." @@ -3503,10 +3534,7 @@ This renders the snippet as ordinary text." (dolist (snippet snippets) (yas--snippet-map-markers (lambda (m) - (goto-char m) - (beginning-of-line) - (prog1 (cons (count-lines (point-min) (point)) - (yas--snapshot-marker-location m)) + (prog1 (cons m (yas--snapshot-line-location m)) (set-marker m nil))) snippet) (let ((ctrl-ov (yas--snapshot-overlay-line-location @@ -3514,23 +3542,27 @@ This renders the snippet as ordinary text." (push (list ctrl-ov dst-base-line snippet) to-move) (delete-overlay (car ctrl-ov)))) (with-current-buffer buf - (setq yas--snippets-to-move (nconc to-move yas--snippets-to-move)))))) + (cl-callf2 nconc to-move yas--snippets-to-move))))) (defun yas--on-buffer-kill () ;; Org mode uses temp buffers for fontification and "native tab", ;; move all the snippets to the original org-mode buffer when it's ;; killed. - (let ((org-marker nil)) + (let ((org-marker nil) + (org-buffer nil)) (when (and yas-minor-mode (or (bound-and-true-p org-edit-src-from-org-mode) (bound-and-true-p org-src--from-org-mode)) (markerp (setq org-marker (or (bound-and-true-p org-edit-src-beg-marker) - (bound-and-true-p org-src--beg-marker))))) + (bound-and-true-p org-src--beg-marker)))) + ;; If the org source buffer is killed before the temp + ;; fontification one, org-marker might point nowhere. + (setq org-buffer (marker-buffer org-marker))) (yas--prepare-snippets-for-move (point-min) (point-max) - (marker-buffer org-marker) org-marker)))) + org-buffer org-marker)))) (add-hook 'kill-buffer-hook #'yas--on-buffer-kill) @@ -3540,18 +3572,16 @@ This renders the snippet as ordinary text." for base-pos = (progn (goto-char (point-min)) (forward-line base-line) (point)) do (yas--snippet-map-markers - (lambda (l-m-r-w) - (goto-char base-pos) - (forward-line (nth 0 l-m-r-w)) - (save-restriction - (narrow-to-region (line-beginning-position) - (line-end-position)) - (yas--restore-marker-location (cdr l-m-r-w))) - (nth 1 l-m-r-w)) + (lambda (saved-location) + (let ((m (pop saved-location))) + (set-marker m (yas--goto-saved-line-location + base-pos saved-location)) + m)) snippet) (goto-char base-pos) - (yas--restore-overlay-location ctrl-ov) - (yas--maybe-move-to-active-field snippet)) + (yas--restore-overlay-line-location base-pos ctrl-ov) + (yas--maybe-move-to-active-field snippet) + (push snippet yas--active-snippets)) (setq yas--snippets-to-move nil)) (defun yas--safely-call-fun (fun) @@ -3756,13 +3786,49 @@ BEG, END and LENGTH like overlay modification hooks." (= beg (yas--field-start field)) ; Insertion at field start? (not (yas--field-modified-p field)))) + +(defun yas--merge-and-drop-dups (list1 list2 cmp key) + ;; `delete-consecutive-dups' + `cl-merge'. + (funcall (if (fboundp 'delete-consecutive-dups) + #'delete-consecutive-dups ; 24.4 + #'delete-dups) + (cl-merge 'list list1 list2 cmp :key key))) + +(defvar yas--before-change-modified-snippets nil) +(make-variable-buffer-local 'yas--before-change-modified-snippets) + +(defun yas--gather-active-snippets (overlay beg end then-delete) + ;; Add active snippets in BEG..END into an OVERLAY keyed entry of + ;; `yas--before-change-modified-snippets'. Return accumulated list. + ;; If THEN-DELETE is non-nil, delete the entry. + (let ((new (yas-active-snippets beg end)) + (old (assq overlay yas--before-change-modified-snippets))) + (prog1 (cond ((and new old) + (setf (cdr old) + (yas--merge-and-drop-dups + (cdr old) new + ;; Sort like `yas-active-snippets'. + #'>= #'yas--snippet-id))) + (new (unless then-delete + ;; Don't add new entry if we're about to + ;; remove it anyway. + (push (cons overlay new) + yas--before-change-modified-snippets)) + new) + (old (cdr old)) + (t nil)) + (when then-delete + (cl-callf2 delq old yas--before-change-modified-snippets))))) + +(defvar yas--todo-snippet-indent nil nil) +(make-variable-buffer-local 'yas--todo-snippet-indent) + (defun yas--on-field-overlay-modification (overlay after? beg end &optional length) "Clears the field and updates mirrors, conditionally. Only clears the field if it hasn't been modified and point is at field start. This hook does nothing if an undo is in progress." - (unless (or (not after?) - yas--inhibit-overlay-hooks + (unless (or yas--inhibit-overlay-hooks (not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824. ;; If a single change hits multiple overlays of the same ;; snippet, then we delete the snippet the first time, @@ -3775,28 +3841,52 @@ field start. This hook does nothing if an undo is in progress." (field (overlay-get overlay 'yas--field)) (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) (if (yas--snippet-live-p snippet) - (save-match-data - (yas--letenv (yas--snippet-expand-env snippet) - (when (yas--skip-and-clear-field-p field beg end length) - ;; We delete text starting from the END of insertion. - (yas--skip-and-clear field end)) - (setf (yas--field-modified-p field) t) - ;; Adjust any pending active fields in case of stacked - ;; expansion. - (let ((pfield field) - (psnippets (yas-active-snippets beg end))) - (while (and pfield psnippets) - (let ((psnippet (pop psnippets))) - (cl-assert (memq pfield (yas--snippet-fields psnippet))) - (yas--advance-end-maybe pfield (overlay-end overlay)) - (setq pfield (yas--snippet-previous-active-field psnippet))))) - (save-excursion - (yas--field-update-display field)) - (yas--update-mirrors snippet))) + (if after? + (save-match-data + (yas--letenv (yas--snippet-expand-env snippet) + (when (yas--skip-and-clear-field-p field beg end length) + ;; We delete text starting from the END of insertion. + (yas--skip-and-clear field end)) + (setf (yas--field-modified-p field) t) + ;; Adjust any pending active fields in case of stacked + ;; expansion. + (let ((pfield field) + (psnippets (yas--gather-active-snippets + overlay beg end t))) + (while (and pfield psnippets) + (let ((psnippet (pop psnippets))) + (cl-assert (memq pfield (yas--snippet-fields psnippet))) + (yas--advance-end-maybe pfield (overlay-end overlay)) + (setq pfield (yas--snippet-previous-active-field psnippet))))) + ;; Update fields now, but delay auto indentation until + ;; post-command. We don't want to run indentation on + ;; the intermediate state where field text might be + ;; removed (and hence the field could be deleted along + ;; with leading indentation). + (let ((yas-indent-line nil)) + (save-excursion + (yas--field-update-display field)) + (yas--update-mirrors snippet)) + (unless (or (not (eq yas-indent-line 'auto)) + (memq snippet yas--todo-snippet-indent)) + (push snippet yas--todo-snippet-indent)))) + ;; Remember active snippets to use for after the change. + (yas--gather-active-snippets overlay beg end nil)) (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!") (delete-overlay overlay))))) +(defun yas--do-todo-snippet-indent () + ;; Do pending indentation of snippet fields, called from + ;; `yas--post-command-handler'. + (when yas--todo-snippet-indent + (save-excursion + (cl-loop for snippet in yas--todo-snippet-indent + do (yas--indent-mirrors-of-snippet + snippet (yas--snippet-field-mirrors snippet))) + (setq yas--todo-snippet-indent nil)))) + (defun yas--auto-fill () + ;; Preserve snippet markers during auto-fill. (let* ((orig-point (point)) (end (progn (forward-paragraph) (point))) (beg (progn (backward-paragraph) (point))) @@ -3806,57 +3896,59 @@ field start. This hook does nothing if an undo is in progress." (dolist (snippet snippets) (dolist (m (yas--collect-snippet-markers snippet)) (when (and (<= beg m) (<= m end)) - (push (yas--snapshot-marker-location m beg end) remarkers))) + (push (cons m (yas--snapshot-location m beg end)) remarkers))) (push (yas--snapshot-overlay-location (yas--snippet-control-overlay snippet) beg end) reoverlays)) (goto-char orig-point) (let ((yas--inhibit-overlay-hooks t)) - (if (null yas--original-auto-fill-function) - ;; Try to get more info on #873/919. - (let ((yas--fill-fun-values `((t ,(default-value 'yas--original-auto-fill-function)))) - (fill-fun-values `((t ,(default-value 'auto-fill-function)))) - ;; Listing 2 buffers with the same value is enough - (print-length 3)) - (save-current-buffer - (dolist (buf (let ((bufs (buffer-list))) - ;; List the current buffer first. - (setq bufs (cons (current-buffer) - (remq (current-buffer) bufs))))) - (set-buffer buf) - (let* ((yf-cell (assq yas--original-auto-fill-function - yas--fill-fun-values)) - (af-cell (assq auto-fill-function fill-fun-values))) - (when (local-variable-p 'yas--original-auto-fill-function) - (if yf-cell (setcdr yf-cell (cons buf (cdr yf-cell))) - (push (list yas--original-auto-fill-function buf) yas--fill-fun-values))) - (when (local-variable-p 'auto-fill-function) - (if af-cell (setcdr af-cell (cons buf (cdr af-cell))) - (push (list auto-fill-function buf) fill-fun-values)))))) - (lwarn '(yasnippet auto-fill bug) :error - "`yas--original-auto-fill-function' unexpectedly nil in %S! Disabling auto-fill. + (if yas--original-auto-fill-function + (funcall yas--original-auto-fill-function) + ;; Shouldn't happen, gather more info about it (see #873/919). + (let ((yas--fill-fun-values `((t ,(default-value 'yas--original-auto-fill-function)))) + (fill-fun-values `((t ,(default-value 'auto-fill-function)))) + ;; Listing 2 buffers with the same value is enough + (print-length 3)) + (save-current-buffer + (dolist (buf (let ((bufs (buffer-list))) + ;; List the current buffer first. + (setq bufs (cons (current-buffer) + (remq (current-buffer) bufs))))) + (set-buffer buf) + (let* ((yf-cell (assq yas--original-auto-fill-function + yas--fill-fun-values)) + (af-cell (assq auto-fill-function fill-fun-values))) + (when (local-variable-p 'yas--original-auto-fill-function) + (if yf-cell (setcdr yf-cell (cons buf (cdr yf-cell))) + (push (list yas--original-auto-fill-function buf) yas--fill-fun-values))) + (when (local-variable-p 'auto-fill-function) + (if af-cell (setcdr af-cell (cons buf (cdr af-cell))) + (push (list auto-fill-function buf) fill-fun-values)))))) + (lwarn '(yasnippet auto-fill bug) :error + "`yas--original-auto-fill-function' unexpectedly nil in %S! Disabling auto-fill. %S `auto-fill-function': %S\n%s" - (current-buffer) yas--fill-fun-values fill-fun-values - (if (fboundp 'backtrace--print-frame) - (with-output-to-string - (mapc (lambda (frame) - (apply #'backtrace--print-frame frame)) - yas--watch-auto-fill-backtrace)) - "")) - ;; Try to avoid repeated triggering of this bug. - (auto-fill-mode -1) - ;; Don't pop up more than once in a session (still log though). - (defvar warning-suppress-types) ; `warnings' is autoloaded by `lwarn'. - (add-to-list 'warning-suppress-types '(yasnippet auto-fill bug))) - (funcall yas--original-auto-fill-function))) + (current-buffer) yas--fill-fun-values fill-fun-values + (if (fboundp 'backtrace--print-frame) + (with-output-to-string + (mapc (lambda (frame) + (apply #'backtrace--print-frame frame)) + yas--watch-auto-fill-backtrace)) + "")) + ;; Try to avoid repeated triggering of this bug. + (auto-fill-mode -1) + ;; Don't pop up more than once in a session (still log though). + (defvar warning-suppress-types) ; `warnings' is autoloaded by `lwarn'. + (add-to-list 'warning-suppress-types '(yasnippet auto-fill bug))))) (save-excursion (setq end (progn (forward-paragraph) (point))) (setq beg (progn (backward-paragraph) (point)))) (save-excursion (save-restriction (narrow-to-region beg end) - (mapc #'yas--restore-marker-location remarkers) + (dolist (remarker remarkers) + (set-marker (car remarker) + (yas--goto-saved-location (cdr remarker)))) (mapc #'yas--restore-overlay-location reoverlays)) (mapc (lambda (snippet) (yas--letenv (yas--snippet-expand-env snippet) @@ -3910,6 +4002,7 @@ Move the overlays, or create them if they do not exit." (defun yas--on-protection-overlay-modification (_overlay after? beg end &optional length) "Commit the snippet if the protection overlay is being killed." (unless (or yas--inhibit-overlay-hooks + yas-inhibit-overlay-modification-protection (not after?) (= length (- end beg)) ; deletion or insertion (yas--undo-in-progress)) @@ -4064,6 +4157,7 @@ After revival, push the `yas--take-care-of-redo' in the (when (yas--maybe-move-to-active-field snippet) (setf (yas--snippet-control-overlay snippet) (yas--make-control-overlay snippet beg end)) (overlay-put (yas--snippet-control-overlay snippet) 'yas--snippet snippet) + (push snippet yas--active-snippets) (when (listp buffer-undo-list) (push `(apply yas--take-care-of-redo ,snippet) buffer-undo-list)))) @@ -4335,35 +4429,54 @@ Meant to be called in a narrowed buffer, does various passes" ;; current paragraph instead of line. ;; ;; 2. Moving snippets from an `org-src' temp buffer into the main org -;; buffer, in this case we need to count the line offsets (because org -;; may add indentation on each line making character positions -;; unreliable). +;; buffer, in this case we need to count the relative line number +;; (because org may add indentation on each line making character +;; positions unreliable). +;; +;; Data formats: +;; (LOCATION) = (REGEXP WS-COUNT) +;; MARKER -> (MARKER . (LOCATION)) +;; OVERLAY -> (OVERLAY LOCATION-BEG LOCATION-END) +;; +;; For `org-src' temp buffer, add a line number to format: +;; (LINE-LOCATION) = (LINE . (LOCATION)) +;; MARKER@LINE -> (MARKER . (LINE-LOCATION)) +;; OVERLAY@LINE -> (OVERLAY LINE-LOCATION-BEG LINE-LOCATION-END) ;; ;; This is all best-effort heuristic stuff, but it should cover 99% of ;; use-cases. -(defun yas--snapshot-marker-location (marker &optional beg end) - "Returns info for restoring MARKER's location after indent. -The returned value is a list of the form (MARKER REGEXP WS-COUNT)." +(defun yas--snapshot-location (position &optional beg end) + "Returns info for restoring POSITIONS's location after indent. +The returned value is a list of the form (REGEXP WS-COUNT). +POSITION may be either a marker or just a buffer position. The +REGEXP matches text between BEG..END which default to the current +line if omitted." + (goto-char position) (unless beg (setq beg (line-beginning-position))) (unless end (setq end (line-end-position))) - (let ((before (split-string (buffer-substring-no-properties beg marker) + (let ((before (split-string (buffer-substring-no-properties beg position) "[[:space:]\n]+" t)) - (after (split-string (buffer-substring-no-properties marker end) + (after (split-string (buffer-substring-no-properties position end) "[[:space:]\n]+" t))) - (list marker - (concat "[[:space:]\n]*" + (list (concat "[[:space:]\n]*" (mapconcat (lambda (s) - (if (eq s marker) "\\(\\)" + (if (eq s position) "\\(\\)" (regexp-quote s))) - (nconc before (list marker) after) + (nconc before (list position) after) "[[:space:]\n]*")) - (progn (goto-char marker) - (skip-chars-forward "[:space:]\n" end) - (- (point) marker))))) + (progn (skip-chars-forward "[:space:]\n" end) + (- (point) position))))) + +(defun yas--snapshot-line-location (position &optional beg end) + "Like `yas--snapshot-location', but return also line number. +Returned format is (LINE REGEXP WS-COUNT)." + (goto-char position) + (cons (count-lines (point-min) (line-beginning-position)) + (yas--snapshot-location position beg end))) (defun yas--snapshot-overlay-location (overlay beg end) - "Like `yas--snapshot-marker-location' for overlays. + "Like `yas--snapshot-location' for overlays. The returned format is (OVERLAY (RE WS) (RE WS)). Either of the (RE WS) lists may be nil if the start or end, respectively, of the overlay is outside the range BEG .. END." @@ -4371,67 +4484,59 @@ of the overlay is outside the range BEG .. END." (oend (overlay-end overlay))) (list overlay (when (and (<= beg obeg) (< obeg end)) - (cdr (yas--snapshot-marker-location obeg beg end))) + (yas--snapshot-location obeg beg end)) (when (and (<= beg oend) (< oend end)) - (cdr (yas--snapshot-marker-location oend beg end)))))) + (yas--snapshot-location oend beg end))))) (defun yas--snapshot-overlay-line-location (overlay) "Return info for restoring OVERLAY's line based location. The returned format is (OVERLAY (LINE RE WS) (LINE RE WS))." - (let ((loc-beg (progn (goto-char (overlay-start overlay)) - (yas--snapshot-marker-location (point)))) - (loc-end (progn (goto-char (overlay-end overlay)) - (yas--snapshot-marker-location (point))))) - (setcar loc-beg (count-lines (point-min) (progn (goto-char (car loc-beg)) - (line-beginning-position)))) - (setcar loc-end (count-lines (point-min) (progn (goto-char (car loc-end)) - (line-beginning-position)))) - (list overlay loc-beg loc-end))) - -(defun yas--goto-saved-location (regexp ws-count) - "Move point to location saved by `yas--snapshot-marker-location'. -Buffer must be narrowed to BEG..END used to create the snapshot info." - (goto-char (point-min)) - (if (not (looking-at regexp)) - (lwarn '(yasnippet re-marker) :warning - "Couldn't find: %S" regexp) - (goto-char (match-beginning 1)) - (skip-chars-forward "[:space:]\n") - (skip-chars-backward "[:space:]\n" (- (point) ws-count)))) - -(defun yas--restore-marker-location (re-marker) - "Restores marker based on info from `yas--snapshot-marker-location'. + (list overlay + (yas--snapshot-line-location (overlay-start overlay)) + (yas--snapshot-line-location (overlay-end overlay)))) + +(defun yas--goto-saved-location (re-count) + "Move to and return point saved by `yas--snapshot-location'. Buffer must be narrowed to BEG..END used to create the snapshot info." - (apply #'yas--goto-saved-location (cdr re-marker)) - (set-marker (car re-marker) (point))) + (let ((regexp (pop re-count)) + (ws-count (pop re-count))) + (goto-char (point-min)) + (if (not (looking-at regexp)) + (lwarn '(yasnippet re-marker) :warning + "Couldn't find: %S" regexp) + (goto-char (match-beginning 1)) + (skip-chars-forward "[:space:]\n") + (skip-chars-backward "[:space:]\n" (- (point) ws-count))) + (point))) (defun yas--restore-overlay-location (ov-locations) - "Restores marker based on info from `yas--snapshot-marker-location'. + "Restores marker based on info from `yas--snapshot-overlay-location'. Buffer must be narrowed to BEG..END used to create the snapshot info." (cl-destructuring-bind (overlay loc-beg loc-end) ov-locations (move-overlay overlay (if (not loc-beg) (overlay-start overlay) - (apply #'yas--goto-saved-location loc-beg) - (point)) + (yas--goto-saved-location loc-beg)) (if (not loc-end) (overlay-end overlay) - (apply #'yas--goto-saved-location loc-end) - (point))))) - - -(defun yas--restore-overlay-line-location (ov-locations) - "Restores overlay based on info from `yas--snapshot-overlay-line-location'." + (yas--goto-saved-location loc-end))))) + +(defun yas--goto-saved-line-location (base-pos l-re-count) + "Move to and return point saved by `yas--snapshot-line-location'. +Additionally requires BASE-POS to tell where the line numbers are +relative to." + (goto-char base-pos) + (forward-line (pop l-re-count)) (save-restriction - (move-overlay (car ov-locations) - (save-excursion - (forward-line (car (nth 1 ov-locations))) - (narrow-to-region (line-beginning-position) (line-end-position)) - (apply #'yas--goto-saved-location (cdr (nth 1 ov-locations))) - (point)) - (save-excursion - (forward-line (car (nth 2 ov-locations))) - (narrow-to-region (line-beginning-position) (line-end-position)) - (apply #'yas--goto-saved-location (cdr (nth 2 ov-locations))) - (point))))) + (narrow-to-region (line-beginning-position) + (line-end-position)) + (yas--goto-saved-location l-re-count))) + +(defun yas--restore-overlay-line-location (base-pos ov-locations) + "Restores marker based on info from `yas--snapshot-overlay-line-location'." + (cl-destructuring-bind (overlay beg-l-r-w end-l-r-w) + ov-locations + (move-overlay overlay + (yas--goto-saved-line-location base-pos beg-l-r-w) + (yas--goto-saved-line-location base-pos end-l-r-w)))) (defun yas--indent-region (from to snippet) "Indent the lines between FROM and TO with `indent-according-to-mode'. @@ -4450,14 +4555,16 @@ The SNIPPET's markers are preserved." (let ((remarkers nil)) (dolist (m snippet-markers) (when (and (<= bol m) (<= m eol)) - (push (yas--snapshot-marker-location m bol eol) + (push (cons m (yas--snapshot-location m bol eol)) remarkers))) (unwind-protect (progn (back-to-indentation) (indent-according-to-mode)) (save-restriction (narrow-to-region bol (line-end-position)) - (mapc #'yas--restore-marker-location remarkers)))) + (dolist (remarker remarkers) + (set-marker (car remarker) + (yas--goto-saved-location (cdr remarker))))))) while (and (zerop (forward-line 1)) (< (point) to))))))) @@ -4585,7 +4692,10 @@ SAVED-QUOTES is the in format returned by `yas--save-backquotes'." (defun yas--scan-sexps (from count) (ignore-errors (save-match-data ; `scan-sexps' may modify match data. + ;; Parse using the syntax table corresponding to the yasnippet syntax. (with-syntax-table (standard-syntax-table) + ;; And ignore syntax-table properties that may have been placed by the + ;; major mode since these aren't related to the yasnippet syntax. (let ((parse-sexp-lookup-properties nil)) (scan-sexps from count)))))) @@ -4621,7 +4731,14 @@ When multiple expressions are found, only the last one counts." ;; (save-excursion (while (re-search-forward yas--field-regexp nil t) - (let* ((real-match-end-0 (yas--scan-sexps (1+ (match-beginning 0)) 1)) + (let* ((brace-scan (yas--scan-sexps (1+ (match-beginning 0)) 1)) + ;; if the `brace-scan' didn't reach a brace, we have a + ;; snippet with invalid escaping, probably a closing + ;; brace escaped with two backslashes (github#979). But + ;; be lenient, because we can. + (real-match-end-0 (if (eq ?} (char-before brace-scan)) + brace-scan + (point))) (number (and (match-string-no-properties 1) (string-to-number (match-string-no-properties 1)))) (brand-new-field (and real-match-end-0 @@ -4755,46 +4872,58 @@ When multiple expressions are found, only the last one counts." (parent 1) (t 0)))))) +(defun yas--snippet-field-mirrors (snippet) + ;; Make a list of (FIELD . MIRROR). + (cl-sort + (cl-mapcan (lambda (field) + (mapcar (lambda (mirror) + (cons field mirror)) + (yas--field-mirrors field))) + (yas--snippet-fields snippet)) + ;; Then sort this list so that entries with mirrors with + ;; parent fields appear before. This was important for + ;; fixing #290, and also handles the case where a mirror in + ;; a field causes another mirror to need reupdating. + #'> :key (lambda (fm) (yas--calculate-mirror-depth (cdr fm))))) + +(defun yas--indent-mirrors-of-snippet (snippet &optional f-ms) + ;; Indent mirrors of SNIPPET. F-MS is the return value of + ;; (yas--snippet-field-mirrors SNIPPET). + (when (eq yas-indent-line 'auto) + (let ((yas--inhibit-overlay-hooks t)) + (cl-loop for (beg . end) in + (cl-sort (mapcar (lambda (f-m) + (let ((mirror (cdr f-m))) + (cons (yas--mirror-start mirror) + (yas--mirror-end mirror)))) + (or f-ms + (yas--snippet-field-mirrors snippet))) + #'< :key #'car) + do (yas--indent-region beg end snippet))))) + (defun yas--update-mirrors (snippet) "Update all the mirrors of SNIPPET." (yas--save-restriction-and-widen (save-excursion - (cl-loop - for (field . mirror) - in (cl-sort - ;; Make a list of (FIELD . MIRROR). - (cl-mapcan (lambda (field) - (mapcar (lambda (mirror) - (cons field mirror)) - (yas--field-mirrors field))) - (yas--snippet-fields snippet)) - ;; Then sort this list so that entries with mirrors with - ;; parent fields appear before. This was important for - ;; fixing #290, and also handles the case where a mirror in - ;; a field causes another mirror to need reupdating. - #'> :key (lambda (fm) (yas--calculate-mirror-depth (cdr fm)))) - ;; Before updating a mirror with a parent-field, maybe advance - ;; its start (#290). - do (let ((parent-field (yas--mirror-parent-field mirror))) - (when parent-field - (yas--advance-start-maybe mirror (yas--fom-start parent-field)))) - ;; Update this mirror. - do (yas--mirror-update-display mirror field) - ;; Delay indenting until we're done all mirrors. We must do - ;; this to avoid losing whitespace between fields that are - ;; still empty (i.e., they will be non-empty after updating). - when (eq yas-indent-line 'auto) - collect (cons (yas--mirror-start mirror) (yas--mirror-end mirror)) - into indent-regions - ;; `yas--place-overlays' is needed since the active field and - ;; protected overlays might have been changed because of insertions - ;; in `yas--mirror-update-display'. - do (let ((active-field (yas--snippet-active-field snippet))) - (when active-field (yas--place-overlays snippet active-field))) - finally do - (let ((yas--inhibit-overlay-hooks t)) - (cl-loop for (beg . end) in (cl-sort indent-regions #'< :key #'car) - do (yas--indent-region beg end snippet))))))) + (let ((f-ms (yas--snippet-field-mirrors snippet))) + (cl-loop + for (field . mirror) in f-ms + ;; Before updating a mirror with a parent-field, maybe advance + ;; its start (#290). + do (let ((parent-field (yas--mirror-parent-field mirror))) + (when parent-field + (yas--advance-start-maybe mirror (yas--fom-start parent-field)))) + ;; Update this mirror. + do (yas--mirror-update-display mirror field) + ;; `yas--place-overlays' is needed since the active field and + ;; protected overlays might have been changed because of insertions + ;; in `yas--mirror-update-display'. + do (let ((active-field (yas--snippet-active-field snippet))) + (when active-field (yas--place-overlays snippet active-field)))) + ;; Delay indenting until we're done all mirrors. We must do + ;; this to avoid losing whitespace between fields that are + ;; still empty (i.e., they will be non-empty after updating). + (yas--indent-mirrors-of-snippet snippet f-ms))))) (defun yas--mirror-update-display (mirror field) "Update MIRROR according to FIELD (and mirror transform)." @@ -4852,6 +4981,7 @@ When multiple expressions are found, only the last one counts." ;; Don't pop up more than once in a session (still log though). (defvar warning-suppress-types) ; `warnings' is autoloaded by `lwarn'. (add-to-list 'warning-suppress-types '(yasnippet auto-fill bug))) + (yas--do-todo-snippet-indent) (condition-case err (progn (yas--finish-moving-snippets) (cond ((eq 'undo this-command) -- 2.47.3