summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.el1
-rw-r--r--lisp/km-ace-link.el5
-rw-r--r--lisp/km-bib.el3
-rw-r--r--lisp/km-compile.el6
-rw-r--r--lisp/km-diff.el9
-rw-r--r--lisp/km-dired.el9
-rw-r--r--lisp/km-editing.el11
-rw-r--r--lisp/km-gnus.el47
-rw-r--r--lisp/km-magit.el132
-rw-r--r--lisp/km-org.el9
-rw-r--r--lisp/km-projectile.el31
-rw-r--r--lisp/km-shell.el4
-rw-r--r--lisp/km-util.el8
13 files changed, 136 insertions, 139 deletions
diff --git a/init.el b/init.el
index 4736b02..63d6815 100644
--- a/init.el
+++ b/init.el
@@ -21,7 +21,6 @@
;;; Code:
(require 'cl-lib)
-(require 'dash)
(require 's)
(require 'bind-key)
diff --git a/lisp/km-ace-link.el b/lisp/km-ace-link.el
index 0bb8ee6..1fc75c3 100644
--- a/lisp/km-ace-link.el
+++ b/lisp/km-ace-link.el
@@ -21,7 +21,6 @@
;;; Code:
(require 'avy)
-(require 'dash)
(require 'wid-edit)
(declare-function dired-next-line "dired" (arg))
@@ -31,8 +30,8 @@
(save-excursion
(goto-char (window-start))
(while (< (point) end)
- (--when-let (dired-next-line 1)
- (push it points)))
+ (when-let ((pt (dired-next-line 1)))
+ (push pt points)))
(nreverse points))))
diff --git a/lisp/km-bib.el b/lisp/km-bib.el
index 9625ff8..6d364c0 100644
--- a/lisp/km-bib.el
+++ b/lisp/km-bib.el
@@ -21,7 +21,6 @@
;;; Code:
(require 'bibtex)
-(require 'dash)
(require 'org)
(defvar km/bibtex-unimportant-title-words
@@ -231,7 +230,7 @@ point. The link is opened using the settings of
(defun km/copy-doi-as-kill ()
"Copy DOI at point to kill ring."
(interactive)
- (-when-let (doi (km/doi-at-point))
+ (when-let ((doi (km/doi-at-point)))
(kill-new (message "%s" (concat "doi:" doi)))))
(defun km/doi-at-point ()
diff --git a/lisp/km-compile.el b/lisp/km-compile.el
index 9ccb7a5..2e8e571 100644
--- a/lisp/km-compile.el
+++ b/lisp/km-compile.el
@@ -22,7 +22,7 @@
(require 'compile)
-(require 'dash)
+(require 'seq)
(defvar km/compilation-buffer-name-prefix "compilation: ")
@@ -85,7 +85,7 @@ Otherwise, if ARG is non-nil, prompt with buffers from
(= arg 0))
(get-buffer (km/compilation-name-by-directory)))
(t
- (let ((cbufs (-map #'buffer-name (km/compilation-buffer-list)))
+ (let ((cbufs (mapcar #'buffer-name (km/compilation-buffer-list)))
buf)
(cl-case (length cbufs)
(0 (user-error "No compilation buffers found"))
@@ -95,7 +95,7 @@ Otherwise, if ARG is non-nil, prompt with buffers from
buf))))
(defun km/compilation-buffer-list ()
- (-filter #'km/compilation-buffer-p (buffer-list)))
+ (seq-filter #'km/compilation-buffer-p (buffer-list)))
(defun km/compile-make-pdf-target (command)
(and (string-match (rx string-start
diff --git a/lisp/km-diff.el b/lisp/km-diff.el
index 999d734..a4b855b 100644
--- a/lisp/km-diff.el
+++ b/lisp/km-diff.el
@@ -20,7 +20,6 @@
;;; Code:
-(require 'dash)
(require 'diff)
(require 'ediff)
@@ -45,10 +44,10 @@
(let ((windows (window-list)))
(unless (= (length windows) 2)
(user-error "Function restricted to two-window frames"))
- (-if-let* ((file-a (buffer-file-name
- (window-buffer (car windows))))
- (file-b (buffer-file-name
- (window-buffer (cadr windows)))))
+ (if-let ((file-a (buffer-file-name
+ (window-buffer (car windows))))
+ (file-b (buffer-file-name
+ (window-buffer (cadr windows)))))
(funcall diff-func file-a file-b)
(user-error "At least one buffer is not visiting a file"))))
diff --git a/lisp/km-dired.el b/lisp/km-dired.el
index 706a543..2041efc 100644
--- a/lisp/km-dired.el
+++ b/lisp/km-dired.el
@@ -20,7 +20,6 @@
;;; Code:
-(require 'dash)
(require 'dired)
(require 'org)
(require 'km-util)
@@ -81,17 +80,17 @@
"Run 'touch -h' on makred files (or next ARG)."
(interactive "p")
(setq arg (and current-prefix-arg arg))
- (--when-let (dired-get-marked-files nil arg)
- (apply #'call-process "touch" nil nil nil "-h" it)))
+ (when-let ((fname (dired-get-marked-files nil arg)))
+ (apply #'call-process "touch" nil nil nil "-h" fname)))
;;;###autoload
(defun km/dired-copy-last-mtime-as-kill ()
"Copy last modification time for file at point."
(interactive)
- (--when-let (dired-get-filename nil 'noerror)
+ (when-let ((fname (dired-get-filename nil 'noerror)))
(kill-new (message "%s" (format-time-string
"%Y%m%d%H%M.%S"
- (nth 5 (file-attributes it)))))))
+ (nth 5 (file-attributes fname)))))))
;;;###autoload
(defun km/dired-beginning-of-buffer ()
diff --git a/lisp/km-editing.el b/lisp/km-editing.el
index 89935a6..f11c20b 100644
--- a/lisp/km-editing.el
+++ b/lisp/km-editing.el
@@ -20,7 +20,6 @@
;;; Code:
-(require 'dash)
(require 'outline)
(require 's)
(require 'select)
@@ -226,11 +225,11 @@ touches."
(defun km/occur ()
"Call `occur' with active region or symbol at point."
(interactive)
- (--when-let (if (use-region-p)
- (buffer-substring-no-properties
- (region-beginning) (region-end))
- (thing-at-point 'symbol))
- (push it regexp-history))
+ (when-let ((text (if (use-region-p)
+ (buffer-substring-no-properties
+ (region-beginning) (region-end))
+ (thing-at-point 'symbol))))
+ (push text regexp-history))
(call-interactively 'occur))
diff --git a/lisp/km-gnus.el b/lisp/km-gnus.el
index 9190777..dee7d76 100644
--- a/lisp/km-gnus.el
+++ b/lisp/km-gnus.el
@@ -20,7 +20,6 @@
;;; Code:
-(require 'dash)
(require 'projectile)
(require 'gnus)
(require 'gnus-group)
@@ -56,35 +55,35 @@ is off."
(save-excursion
(goto-char (point-max))
(widget-forward -1)
- (--when-let (or (get-text-property (point) 'gnus-string)
- (get-text-property (point) 'shr-url))
- (kill-new it)))))
+ (when-let ((link (or (get-text-property (point) 'gnus-string)
+ (get-text-property (point) 'shr-url))))
+ (kill-new link)))))
(defun km/gnus--gmane-link (&optional perma)
(with-current-buffer gnus-original-article-buffer
- (-when-let* ((blink (message-field-value "Archived-At"))
- (link (or (and (string-match
- (rx string-start
- (zero-or-more space)
- "<"
- (group (one-or-more (not (any ">"))))
- ">"
- string-end)
- blink)
- (match-string 1 blink))
- blink)))
+ (when-let ((blink (message-field-value "Archived-At"))
+ (link (or (and (string-match
+ (rx string-start
+ (zero-or-more space)
+ "<"
+ (group (one-or-more (not (any ">"))))
+ ">"
+ string-end)
+ blink)
+ (match-string 1 blink))
+ blink)))
(if perma
link
(replace-regexp-in-string "\\`http://permalink\.gmane\.org/"
- "http://thread.gmane.org/"
- link)))))
+ "http://thread.gmane.org/"
+ link)))))
(defun km/gnus-copy-gmane-link-as-kill (&optional perma)
(interactive "P")
(km/gnus-summary-set-current-article)
(with-current-buffer gnus-original-article-buffer
- (--when-let (km/gnus--gmane-link perma)
- (kill-new (message "%s" it)))))
+ (when-let ((link (km/gnus--gmane-link perma)))
+ (kill-new (message "%s" link)))))
(defun km/gnus-copy-message-link (follow)
"Copy link for current message.
@@ -95,19 +94,19 @@ argument FOLLOW, follow link instead of copying it."
(km/gnus-summary-set-current-article)
(with-current-buffer gnus-original-article-buffer
(save-excursion
- (--when-let (or (km/gnus--gmane-link)
- (km/gnus--last-message-link))
+ (when-let ((link (or (km/gnus--gmane-link)
+ (km/gnus--last-message-link))))
(funcall (if follow
#'browse-url
(lambda (s) (kill-new (message "%s" s))))
- it)))))
+ link)))))
;;;###autoload
(defun km/gnus-copy-message-id-as-kill ()
(interactive)
(with-current-buffer gnus-original-article-buffer
- (--when-let (message-field-value "Message-ID")
- (kill-new (message "%s" it)))))
+ (when-let ((mid (message-field-value "Message-ID")))
+ (kill-new (message "%s" mid)))))
(defun km/gnus-open-github-patch ()
"Open patch from GitHub email."
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index a53768e..11584c1 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -128,17 +128,17 @@ branch."
"Perform a fast-forward merge of the upstream branch.
\n(git merge --no-edit --ff-only <upstream>)"
(interactive)
- (--if-let (magit-get-upstream-branch)
- (magit-merge-plain it '("--ff-only"))
- (user-error "No upstream branch")))
+ (magit-merge-plain (or (magit-get-upstream-branch)
+ (user-error "No upstream branch"))
+ '("--ff-only")))
(defun km/magit-ff-merge-push ()
"Perform a fast-forward merge of the push branch.
\n(git merge --no-edit --ff-only <push>)"
(interactive)
- (--if-let (magit-get-push-branch)
- (magit-merge-plain it '("--ff-only"))
- (user-error "No push branch")))
+ (magit-merge-plain (or (magit-get-push-branch)
+ (user-error "No push branch"))
+ '("--ff-only")))
;;;###autoload
(defun km/magit-merge-pull-message (rev)
@@ -154,9 +154,9 @@ second if REV is the name of a remote branch.
This assumes that you are pulling PRs into your 'refs/pull/'
namespace."
- (-when-let (pr (--when-let (magit-rev-name rev "refs/pull/*")
- (and (string-match "\\`pull/.+/\\([0-9]+\\)\\'" it)
- (match-string 1 it))))
+ (when-let ((name (magit-rev-name rev "refs/pull/*"))
+ (pr (and (string-match "\\`pull/.+/\\([0-9]+\\)\\'" name)
+ (match-string 1 name))))
(cond ((magit-local-branch-p rev)
(format "Merge branch '%s' [#%s]" rev pr))
((magit-remote-branch-p rev)
@@ -208,8 +208,8 @@ This is equivalent to running `magit-branch-and-checkout' with
START-POINT set to the current branch.
\n(git checkout -b BRANCH)"
(interactive (list (magit-read-string "Branch name" nil nil
- (--when-let (magit-get-current-branch)
- (concat it "-tmp")))))
+ (when-let ((b (magit-get-current-branch)))
+ (concat b "-tmp")))))
(magit-run-git "checkout" "-b" branch))
(defun km/magit-branch--get-versions (branch suffix)
@@ -532,15 +532,15 @@ argument."
(defun km/magit-describe (rev)
"Run 'git describe' on REV."
(interactive
- (list (or (-when-let (section (magit-current-section))
+ (list (or (when-let ((section (magit-current-section)))
(cond
((memq (oref section type) '(commit branch))
(oref section value))
((derived-mode-p 'magit-revision-mode)
magit-buffer-revision)))
(magit-read-branch-or-commit "Revision"))))
- (--when-let (and rev (magit-git-string "describe" rev))
- (kill-new (message "%s" it))))
+ (when-let ((desc (and rev (magit-git-string "describe" rev))))
+ (kill-new (message "%s" desc))))
(defun km/magit-rev-ancestor-p (rev-a rev-b)
"Report whether REV-A is the ancestor of REV-B."
@@ -687,10 +687,10 @@ argument. Interactively, this can be accessed using the command
(concat push ".."))
(t
(concat ".." atpoint))))))
- (--when-let (and (derived-mode-p 'magit-revision-mode)
- magit-buffer-revision)
- (and (magit-rev-verify (concat it "^2"))
- (concat it "^-1"))))))
+ (when-let ((rev (and (derived-mode-p 'magit-revision-mode)
+ magit-buffer-revision)))
+ (and (magit-rev-verify (concat rev "^2"))
+ (concat rev "^-1"))))))
(if range
(magit-log-setup-buffer (list range) args files)
(call-interactively #'magit-log-current))))
@@ -731,35 +731,35 @@ argument. Interactively, this can be accessed using the command
(defun km/magit-cherry-dwim ()
(interactive)
- (-let [(head . upstream)
- (if (eq major-mode 'magit-log-mode)
- (let ((range magit-buffer-revisions))
- (and range
- (string-match magit-range-re range)
- (cons (match-string 3 range)
- (match-string 1 range))))
- (let ((section (magit-current-section))
- (current-branch (magit-get-current-branch)))
- (pcase (list (oref section type)
- (oref section value))
- (`(unpushed "@{upstream}..")
- (cons current-branch (magit-get-upstream-branch)))
- (`(unpulled "..@{upstream}")
- (cons (magit-get-upstream-branch) current-branch))
- ;; Don't try to match "@{push}" because
- ;; `magit-insert-unpulled-from-pushremote' and
- ;; `magit-insert-unpulled-from-pushremote' avoid it to
- ;; be compatible with all push.default settings.
- (`(unpushed ,_)
- (cons current-branch (magit-get-push-branch)))
- (`(unpulled ,_)
- (cons (magit-get-push-branch) current-branch)))))]
+ (pcase-let ((`(,head . ,upstream)
+ (if (eq major-mode 'magit-log-mode)
+ (let ((range magit-buffer-revisions))
+ (and range
+ (string-match magit-range-re range)
+ (cons (match-string 3 range)
+ (match-string 1 range))))
+ (let ((section (magit-current-section))
+ (current-branch (magit-get-current-branch)))
+ (pcase (list (oref section type)
+ (oref section value))
+ (`(unpushed "@{upstream}..")
+ (cons current-branch (magit-get-upstream-branch)))
+ (`(unpulled "..@{upstream}")
+ (cons (magit-get-upstream-branch) current-branch))
+ ;; Don't try to match "@{push}" because
+ ;; `magit-insert-unpulled-from-pushremote' and
+ ;; `magit-insert-unpulled-from-pushremote' avoid it to
+ ;; be compatible with all push.default settings.
+ (`(unpushed ,_)
+ (cons current-branch (magit-get-push-branch)))
+ (`(unpulled ,_)
+ (cons (magit-get-push-branch) current-branch)))))))
(if (and head upstream)
(magit-cherry head upstream)
(call-interactively #'magit-cherry))))
(defun km/magit--insert-count-lines (rev counts)
- (-let [(n-behind n-ahead) counts]
+ (pcase-let ((`(,n-behind ,n-ahead) counts))
(when (> n-ahead 0)
(magit-insert-section (unpushed (concat rev ".."))
(magit-insert-heading
@@ -971,13 +971,13 @@ COMMIT."
(km/magit-copy-commit-summary magit-buffer-revision)))
(defun km/magit-copy-region-commits (&optional read-separator)
- (--when-let (magit-region-values 'commit)
+ (when-let ((commit (magit-region-values 'commit)))
(deactivate-mark)
(kill-new
(message
"%s"
(mapconcat #'identity
- it
+ commit
(if read-separator (read-string "Separator: ") ", "))))))
(defun km/magit-copy--truncated-message (msg)
@@ -1031,12 +1031,12 @@ function."
(defun km/magit-github-url-from-bugref ()
;; `bug-reference-url-format' may be defined in an untracked
;; `.dir-locals.el`, so do this from the main worktree.
- (-when-let* ((wtree (caar (magit-list-worktrees)))
- (url
- (with-temp-buffer
- (let ((default-directory (file-name-as-directory wtree)))
- (hack-dir-local-variables-non-file-buffer)
- bug-reference-url-format))))
+ (when-let ((wtree (caar (magit-list-worktrees)))
+ (url
+ (with-temp-buffer
+ (let ((default-directory (file-name-as-directory wtree)))
+ (hack-dir-local-variables-non-file-buffer)
+ bug-reference-url-format))))
(and url
(string-match "\\`https://github.com/[^/]+/[^/]+" url)
(match-string 0 url))))
@@ -1057,29 +1057,29 @@ function."
(let ((ln (lambda (loc)
(save-restriction
(1+ (count-lines (point-min) loc))))))
- (-when-let* ((rev (or magit-buffer-revision
- (magit-rev-parse "HEAD")))
- (fname (magit-file-relative-name))
- (lines (if (use-region-p)
- (prog1 (format "%s-L%s"
- (funcall ln (region-beginning))
- (1- (funcall ln (region-end))))
- (deactivate-mark))
- (funcall ln (point)))))
+ (when-let ((rev (or magit-buffer-revision
+ (magit-rev-parse "HEAD")))
+ (fname (magit-file-relative-name))
+ (lines (if (use-region-p)
+ (prog1 (format "%s-L%s"
+ (funcall ln (region-beginning))
+ (1- (funcall ln (region-end))))
+ (deactivate-mark))
+ (funcall ln (point)))))
(format "%s/blob/%s/%s#L%s"
(or (km/magit-github-url) "")
rev fname lines))))
(defun km/magit-github-commit-link ()
- (--when-let (or (and (eq major-mode 'magit-revision-mode)
- magit-buffer-revision)
- (and (derived-mode-p 'magit-mode)
- (let ((sec (magit-current-section)))
- (and (eq (oref sec type) 'commit)
- (oref sec value)))))
+ (when-let ((rev (or (and (eq major-mode 'magit-revision-mode)
+ magit-buffer-revision)
+ (and (derived-mode-p 'magit-mode)
+ (let ((sec (magit-current-section)))
+ (and (eq (oref sec type) 'commit)
+ (oref sec value)))))))
(format "%s/commit/%s"
(or (km/magit-github-url) "")
- (magit-rev-parse it))))
+ (magit-rev-parse rev))))
(defun km/magit-github-diff-link ()
(when (derived-mode-p 'magit-diff-mode)
diff --git a/lisp/km-org.el b/lisp/km-org.el
index 8e8927a..0ade476 100644
--- a/lisp/km-org.el
+++ b/lisp/km-org.el
@@ -21,7 +21,6 @@
;;; Code:
(require 'cl-lib)
-(require 'dash)
(require 'org)
(require 'org-link-edit)
(require 'ox-ascii)
@@ -598,9 +597,11 @@ to be easily overriden.")
(defun km/org-open-annex-file ()
"Open a git annex file with `org-open-file'."
(interactive)
- (--if-let (magit-annex-present-files)
- (org-open-file (magit-completing-read "Open annex file" it nil t))
- (message "No annex files found")))
+ (org-open-file
+ (magit-completing-read "Open annex file"
+ (or (magit-annex-present-files)
+ (user-error "No annex files found"))
+ nil t)))
(autoload 'km/read-recent-file "km-files")
;;;###autoload
diff --git a/lisp/km-projectile.el b/lisp/km-projectile.el
index cb4d0fe..e22eeae 100644
--- a/lisp/km-projectile.el
+++ b/lisp/km-projectile.el
@@ -77,8 +77,8 @@ names separated by a space."
(org-element-property :path el))
(and (derived-mode-p 'dired-mode)
(dired-get-marked-files 'nodir nil))
- (--when-let (thing-at-point 'filename)
- (and (file-exists-p it) it)))))
+ (when-let ((fname (thing-at-point 'filename)))
+ (and (file-exists-p fname) fname)))))
(when fname
(mapconcat
`(lambda (f) (file-relative-name f ,(projectile-project-root)))
@@ -97,7 +97,7 @@ names separated by a space."
If point is on a file, copy this as the file name. Otherwise,
use the name of the current file."
(interactive)
- (-when-let (fname (km/projectile-project-filename))
+ (when-let ((fname (km/projectile-project-filename)))
(if (eq last-command 'kill-region)
(kill-append fname nil)
(kill-new fname))
@@ -109,10 +109,11 @@ use the name of the current file."
Currently, only Python mode is supported."
(interactive)
(when (derived-mode-p 'python-mode)
- (-when-let* ((fname (km/projectile-project-filename))
- (module (--> fname
- (replace-regexp-in-string "/" "." it nil t)
- (replace-regexp-in-string "\\.py" "" it t t))))
+ (when-let ((fname (km/projectile-project-filename))
+ (module (replace-regexp-in-string
+ "\\.py" ""
+ (replace-regexp-in-string "/" "." fname nil t)
+ t t)))
(if (eq last-command 'kill-region)
(kill-append module nil)
(kill-new module))
@@ -157,16 +158,16 @@ Thing is a character representing
"Restore saved thing for current project.
Return nil if there is no thing saved for the current project."
(interactive)
- (-when-let* ((thing-value (lax-plist-get km/projectile-project-saved-thing
- (projectile-project-root)))
- (thing (car thing-value))
- (value (cdr thing-value)))
+ (when-let ((thing-value (lax-plist-get km/projectile-project-saved-thing
+ (projectile-project-root)))
+ (thing (car thing-value))
+ (value (cdr thing-value)))
(cl-case thing
(?.
- (-if-let (buf (marker-buffer value))
- (progn (switch-to-buffer buf)
- (goto-char value))
- (user-error "Buffer no longer exists")))
+ (switch-to-buffer
+ (or (marker-buffer value)
+ (user-error "Buffer no longer exists")))
+ (goto-char value))
(?b
(if (buffer-live-p value)
(switch-to-buffer value)
diff --git a/lisp/km-shell.el b/lisp/km-shell.el
index fd267dd..afbfa72 100644
--- a/lisp/km-shell.el
+++ b/lisp/km-shell.el
@@ -21,7 +21,6 @@
;;; Code:
(require 'comint)
-(require 'dash)
(require 'term)
(defvar km/terminal "urxvt")
@@ -109,7 +108,8 @@ BUFFER defaults to current buffer."
(match-string 1 bname)))))
(defun km/zsh-ansi-term-current-directories ()
- (-distinct (-keep #'km/zsh-ansi-term-directory (buffer-list))))
+ (delete-dups
+ (delq nil (mapcar #'km/zsh-ansi-term-directory (buffer-list)))))
(provide 'km-shell)
;;; km-shell.el ends here
diff --git a/lisp/km-util.el b/lisp/km-util.el
index b8ae4cc..7d6febe 100644
--- a/lisp/km-util.el
+++ b/lisp/km-util.el
@@ -20,7 +20,7 @@
;;; Code:
-(require 'dash)
+(require 'seq)
;; Taken from
;; http://milkbox.net/note/single-file-master-emacs-configuration/.
@@ -31,8 +31,10 @@
'(progn ,@body)))
(defun km/mode-buffers (mode)
- (--filter (with-current-buffer it (derived-mode-p mode))
- (buffer-list)))
+ (seq-filter (lambda (buf)
+ (with-current-buffer buf
+ (derived-mode-p mode)))
+ (buffer-list)))
(defun km/region-or-buffer-line-bounds ()
"Return line bounds for region.