diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-05 01:03:58 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-05 11:18:29 -0200 |
commit | 359a48845905feab401b5dc0783733ff230f8956 (patch) | |
tree | 5ee5eb7039230c74450d043d6a6abb7beb592114 | |
parent | 065ef960b3fcf80ea68dbcbbcca8c276a2d09b07 (diff) |
Refactor sx-compose--goto-tag-header
-rw-r--r-- | sx-compose.el | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sx-compose.el b/sx-compose.el index 8a6edc3..ac6700b 100644 --- a/sx-compose.el +++ b/sx-compose.el @@ -137,20 +137,25 @@ contents to the API, then calls `sx-compose-after-send-functions'." (with-current-buffer buffer (kill-new (buffer-string))))) +(defun sx-compose--goto-tag-header () + "Move to the \"Tags:\" header. +Match data is set so group 1 encompasses any already inserted +tags. Return a list of already inserted tags." + (goto-char (point-min)) + (unless (search-forward-regexp + "^Tags : *\\([^[:space:]].*\\) *$" + (next-single-property-change (point-min) 'sx-compose-separator) + 'noerror) + (error "No Tags header found")) + (split-string (match-string 1) "[[:space:],;]" + 'omit-nulls "[[:space:]]")) + (defun sx-compose--check-tags () "Check if tags in current compose buffer are valid." (save-excursion - (goto-char (point-min)) - (unless (search-forward-regexp - "^Tags : *\\([^[:space:]].*\\) *$" - (next-single-property-change (point-min) 'sx-compose-separator) - 'noerror) - (error "No Tags header found")) (let ((invalid-tags (sx-tag--invalid-name-p - (split-string (match-string 1) "[[:space:],;]" - 'omit-nulls "[[:space:]]") - sx-compose--site))) + sx-compose--site (sx-compose--goto-tag-header)))) (if invalid-tags ;; If the user doesn't want to create the tags, we return ;; nil and sending is aborted. |