Skip to content

Commit

Permalink
Cleanup and preparation for inclusion in GNU ELPA
Browse files Browse the repository at this point in the history
Rename easy-kill-message-nolog to easy-kill-echo.
  • Loading branch information
leoliu committed Apr 5, 2014
1 parent a40258f commit 4e04082
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
12 changes: 0 additions & 12 deletions Makefile

This file was deleted.

43 changes: 21 additions & 22 deletions easy-kill.el
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
;;; easy-kill.el --- kill things easily -*- lexical-binding: t; -*-
;;; easy-kill.el --- kill & mark things easily -*- lexical-binding: t; -*-

;; Copyright (C) 2013-2014 Leo Liu
;; Copyright (C) 2013-2014 Free Software Foundation, Inc.

;; Author: Leo Liu <sdl.web@gmail.com>
;; Version: 0.9.1
;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
;; Keywords: convenience
;; Keywords: killing, convenience
;; Created: 2013-08-12
;; URL: https://github.com/leoliu/easy-kill

Expand Down Expand Up @@ -76,8 +76,7 @@
(?f . filename)
(?d . defun)
(?e . line)
(?b . buffer-file-name)
(?D . defun-name))

This comment has been minimized.

Copy link
@swsnr

swsnr Apr 5, 2014

@leoliu Why's D gone?

This comment has been minimized.

Copy link
@leoliu

leoliu Apr 5, 2014

Author Owner

Ahh, I didn't realise someone was using it. Should I enable it by default?

This comment has been minimized.

Copy link
@swsnr

swsnr via email Apr 5, 2014

This comment has been minimized.

Copy link
@leoliu

leoliu Apr 5, 2014

Author Owner

I was trying to keep the default list of things down. And based on my own experience I haven't used the defun-name much so turned it off for now. Thanks for the kind words.

(?b . buffer-file-name))
"A list of (CHAR . THING).
CHAR is used immediately following `easy-kill' to select THING."
:type '(repeat (cons character symbol))
Expand Down Expand Up @@ -127,7 +126,7 @@ CHAR is used immediately following `easy-kill' to select THING."

(defvar easy-kill-inhibit-message nil)

(defun easy-kill-message-nolog (format-string &rest args)
(defun easy-kill-echo (format-string &rest args)
"Same as `message' except not writing to *Messages* buffer.
Do nothing if `easy-kill-inhibit-message' is non-nil."
(unless easy-kill-inhibit-message
Expand Down Expand Up @@ -202,7 +201,7 @@ candidate property instead."
(move-overlay o (point) (point))
(overlay-put o 'candidate beg)
(let ((easy-kill-inhibit-message nil))
(easy-kill-message-nolog "%s" beg)))
(easy-kill-echo "%s" beg)))
(move-overlay o beg end))
(cond (easy-kill-mark (easy-kill-mark-region)
(easy-kill-indicate-origin))
Expand Down Expand Up @@ -292,12 +291,12 @@ candidate property instead."
(easy-kill-thing-forward (pcase n
(`+ 1)
(`- -1)
(n n))))
(t (let ((bounds (bounds-of-thing-at-point thing)))
(if (not bounds)
(easy-kill-message-nolog "No `%s'" thing)
(easy-kill-adjust-candidate thing (car bounds) (cdr bounds))
(easy-kill-thing-forward (1- n))))))
(_ n))))
(t (pcase (bounds-of-thing-at-point thing)
(`nil (easy-kill-echo "No `%s'" thing))
(`(,start . ,end)
(easy-kill-adjust-candidate thing start end)
(easy-kill-thing-forward (1- n))))))
(when easy-kill-mark
(easy-kill-adjust-candidate (overlay-get easy-kill-candidate 'thing)))))

Expand All @@ -319,7 +318,7 @@ candidate property instead."
(let ((beg (overlay-start easy-kill-candidate))
(end (overlay-end easy-kill-candidate)))
(if (= beg end)
(easy-kill-message-nolog "Empty region")
(easy-kill-echo "Empty region")
(kill-region beg end))))

(put 'easy-kill-mark-region 'easy-kill-exit t)
Expand All @@ -328,7 +327,7 @@ candidate property instead."
(let ((beg (overlay-start easy-kill-candidate))
(end (overlay-end easy-kill-candidate)))
(if (= beg end)
(easy-kill-message-nolog "Empty region")
(easy-kill-echo "Empty region")
(set-mark beg)
(goto-char end)
(activate-mark))))
Expand All @@ -341,7 +340,7 @@ candidate property instead."
(and interprogram-cut-function
(funcall interprogram-cut-function (car kill-ring)))
(setq deactivate-mark t)
(easy-kill-message-nolog "Appended")))
(easy-kill-echo "Appended")))

(defun easy-kill-activate-keymap ()
(let ((map (easy-kill-map)))
Expand Down Expand Up @@ -381,15 +380,15 @@ Temporally activate additional key bindings as follows:
others => save selection and exit."
(interactive "p")
(if (use-region-p)
(if (fboundp 'rectangle-mark-mode)
(with-no-warnings ; new in 24.4
(if (fboundp 'rectangle-mark-mode) ; New in 24.4
(with-no-warnings
(kill-ring-save (region-beginning) (region-end) t))
(kill-ring-save (region-beginning) (region-end)))
(setq easy-kill-mark nil)
(setq easy-kill-append (eq last-command 'kill-region))
(easy-kill-init-candidate n)
(when (zerop (buffer-size))
(easy-kill-message-nolog "Warn: `easy-kill' activated in empty buffer"))
(easy-kill-echo "Warn: `easy-kill' activated in empty buffer"))
(easy-kill-activate-keymap)))

;;;###autoload
Expand Down Expand Up @@ -417,7 +416,7 @@ Temporally activate additional key bindings as follows:
If N is zero, remove the directory part; -, remove the file name
part; +, full path."
(if easy-kill-mark
(easy-kill-message-nolog "Not supported in `easy-mark'")
(easy-kill-echo "Not supported in `easy-mark'")
(let ((file (or buffer-file-name default-directory)))
(when file
(let* ((file (directory-file-name file))
Expand All @@ -432,11 +431,11 @@ part; +, full path."
(defun easy-kill-on-defun-name (_n)
"Get current defun name."
(if easy-kill-mark
(easy-kill-message-nolog "Not supported in `easy-mark'")
(easy-kill-echo "Not supported in `easy-mark'")
(let ((defun-name (add-log-current-defun)))
(if defun-name
(easy-kill-adjust-candidate 'defun-name defun-name)
(easy-kill-message-nolog "No `defun-name' at point")))))
(easy-kill-echo "No `defun-name' at point")))))

;;; Handler for `url'.

Expand Down

0 comments on commit 4e04082

Please sign in to comment.