Move rx calls to local macro
This commit is contained in:
parent
9a24c989c1
commit
21af74d552
81
init.el
81
init.el
|
@ -262,9 +262,10 @@
|
||||||
(t . "xdg-open %s")))
|
(t . "xdg-open %s")))
|
||||||
(setq org-todo-keywords '((sequence "TODO" "STARTED" "DONE")))
|
(setq org-todo-keywords '((sequence "TODO" "STARTED" "DONE")))
|
||||||
(defun cp-copy-line-or-link (prefix-arg)
|
(defun cp-copy-line-or-link (prefix-arg)
|
||||||
"If current line only contains (excluding whitespace) an
|
"Copy address of org link after point, ignoring whitespace,
|
||||||
org-format link, copy the address (not the description) of the
|
link description (if any) and org header and list syntax. If not
|
||||||
link. Otherwise, call `whole-line-or-region-kill-ring-save'."
|
before link or with a prefix arg, call
|
||||||
|
`whole-line-or-region-kill-ring-save'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((point-a (point)))
|
(let ((point-a (point)))
|
||||||
(cl-flet ((copy-to-closing-bracket
|
(cl-flet ((copy-to-closing-bracket
|
||||||
|
@ -273,52 +274,42 @@ link. Otherwise, call `whole-line-or-region-kill-ring-save'."
|
||||||
(re-search-forward "\\]")
|
(re-search-forward "\\]")
|
||||||
(copy-region-as-kill point-b
|
(copy-region-as-kill point-b
|
||||||
(- (point) 1)))))
|
(- (point) 1)))))
|
||||||
(if (not prefix-arg)
|
(cl-macrolet ((before-link
|
||||||
(cond
|
(ending)
|
||||||
((looking-at
|
(append '(rx (zero-or-more "*")
|
||||||
(rx (zero-or-more "*")
|
(zero-or-more blank)
|
||||||
(zero-or-more blank)
|
(optional
|
||||||
(optional
|
(or "- " "+ " "* "
|
||||||
(or "- " "+ " "* "
|
(and (one-or-more (char "0-9"))
|
||||||
(and (one-or-more (char "0-9"))
|
(or ". " ") ")))))
|
||||||
(or ". " ") "))))
|
(list ending))))
|
||||||
"["))
|
(if (not prefix-arg)
|
||||||
(search-forward "[")
|
(cond
|
||||||
(if (looking-at "\\[")
|
((looking-at (before-link "["))
|
||||||
(forward-char))
|
(search-forward "[")
|
||||||
(copy-to-closing-bracket)
|
(if (looking-at "\\[")
|
||||||
(goto-char point-a))
|
(forward-char))
|
||||||
|
(copy-to-closing-bracket)
|
||||||
|
(goto-char point-a))
|
||||||
|
|
||||||
((looking-at
|
((looking-at (before-link "http"))
|
||||||
(rx (zero-or-more "*")
|
(search-forward "http")
|
||||||
(zero-or-more blank)
|
(backward-word)
|
||||||
(optional
|
(let ((point-b (point)))
|
||||||
(or "- " "+ " "* "
|
(re-search-forward (rx (or eol (and printing " "))))
|
||||||
(and (one-or-more (char "0-9"))
|
(copy-region-as-kill point-b
|
||||||
(or ". " ") "))))
|
(- (point) 1)))
|
||||||
"http"))
|
(goto-char point-a))
|
||||||
(search-forward "http")
|
|
||||||
(backward-word)
|
|
||||||
(let ((point-b (point)))
|
|
||||||
(re-search-forward (rx (or eol (and printing " "))))
|
|
||||||
(copy-region-as-kill point-b
|
|
||||||
(- (point) 1)))
|
|
||||||
(goto-char point-a))
|
|
||||||
|
|
||||||
(t ;; (progn
|
(t (whole-line-or-region-kill-ring-save prefix-arg)))
|
||||||
;; (goto-char point-a)
|
|
||||||
;; (whole-line-or-region-kill-ring-save prefix-arg))
|
|
||||||
(whole-line-or-region-kill-ring-save prefix-arg)))
|
|
||||||
|
|
||||||
;; TODO - org-previous-link will land you at the start of
|
;; TODO - org-previous-link will land you at the start of
|
||||||
;; the DESCRIPTION of the previous link, if it has one,
|
;; the DESCRIPTION of the previous link, if it has one,
|
||||||
;; but to the user it will look like they are at the start
|
;; but to the user it will look like they are at the start
|
||||||
;; of the link. Add a case to handle this.
|
;; of the link. Add a case to handle this.
|
||||||
|
|
||||||
|
(whole-line-or-region-kill-ring-save prefix-arg)))))))
|
||||||
|
|
||||||
;; (progn
|
|
||||||
;; (goto-char point-a)
|
|
||||||
;; (whole-line-or-region-kill-ring-save prefix-arg))
|
|
||||||
(whole-line-or-region-kill-ring-save prefix-arg))))))
|
|
||||||
|
|
||||||
|
|
||||||
(require 'ace-jump-mode)
|
(require 'ace-jump-mode)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user