diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2014-04-25 15:51:17 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2014-04-25 15:51:17 +0200 |
commit | bc4fb132f218c2025eeb9218f95f56798343c05a (patch) | |
tree | 50d56ec46972ab2adfaef5548d0b25fb886221c5 /helm-ring.el | |
parent | 9bc2702cf13e5096e391088208cc71e580cf2fd7 (diff) |
Finally reindent with the cl indentation behavior of 24.4.50.
It have font-lock broken in some place but is not broken as in 24.3.90.
So perhaps it is the best option for now.
Diffstat (limited to 'helm-ring.el')
-rw-r--r-- | helm-ring.el | 278 |
1 files changed, 139 insertions, 139 deletions
diff --git a/helm-ring.el b/helm-ring.el index ec8f89f6..fc1f64ce 100644 --- a/helm-ring.el +++ b/helm-ring.el @@ -71,8 +71,8 @@ If nil or zero (disabled), don't truncate candidate, show all." (action . (("Yank" . helm-kill-ring-action) ("Delete" . (lambda (candidate) (cl-loop for cand in (helm-marked-candidates) - do (setq kill-ring - (delete cand kill-ring))))))) + do (setq kill-ring + (delete cand kill-ring))))))) (keymap . ,helm-kill-ring-map) (last-command) (migemo) @@ -81,28 +81,28 @@ If nil or zero (disabled), don't truncate candidate, show all." (defun helm-kill-ring-candidates () (cl-loop for kill in (helm-fast-remove-dups kill-ring :test 'equal) - unless (or (< (length kill) helm-kill-ring-threshold) - (string-match "\\`[\n[:blank:]]+\\'" kill)) - collect kill)) + unless (or (< (length kill) helm-kill-ring-threshold) + (string-match "\\`[\n[:blank:]]+\\'" kill)) + collect kill)) (defun helm-kill-ring-transformer (candidates _source) "Display only the `helm-kill-ring-max-lines-number' lines of candidate." (cl-loop for i in candidates - for nlines = (with-temp-buffer (insert i) (count-lines (point-min) (point-max))) - if (and helm-kill-ring-max-lines-number - (> nlines helm-kill-ring-max-lines-number)) - collect (cons - (with-temp-buffer - (insert i) - (goto-char (point-min)) - (concat - (buffer-substring - (point-min) - (save-excursion - (forward-line helm-kill-ring-max-lines-number) - (point))) - "[...]")) i) - else collect i)) + for nlines = (with-temp-buffer (insert i) (count-lines (point-min) (point-max))) + if (and helm-kill-ring-max-lines-number + (> nlines helm-kill-ring-max-lines-number)) + collect (cons + (with-temp-buffer + (insert i) + (goto-char (point-min)) + (concat + (buffer-substring + (point-min) + (save-excursion + (forward-line helm-kill-ring-max-lines-number) + (point))) + "[...]")) i) + else collect i)) (defun helm-kill-ring-action (str) "Insert STR in `kill-ring' and set STR to the head. @@ -112,24 +112,24 @@ replace with STR as yanked string." (setq kill-ring (delete str kill-ring)) (if (not (eq (helm-attr 'last-command helm-source-kill-ring) 'yank)) (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) - ;; from `yank-pop' - (let ((inhibit-read-only t) - (before (< (point) (mark t)))) - (if before - (funcall (or yank-undo-function 'delete-region) (point) (mark t)) - (funcall (or yank-undo-function 'delete-region) (mark t) (point))) - (setq yank-undo-function nil) - (set-marker (mark-marker) (point) helm-current-buffer) - (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) - ;; Set the window start back where it was in the yank command, - ;; if possible. - (set-window-start (selected-window) yank-window-start t) - (when before - ;; This is like exchange-point-and-mark, but doesn't activate the mark. - ;; It is cleaner to avoid activation, even though the command - ;; loop would deactivate the mark because we inserted text. - (goto-char (prog1 (mark t) - (set-marker (mark-marker) (point) helm-current-buffer)))))) + ;; from `yank-pop' + (let ((inhibit-read-only t) + (before (< (point) (mark t)))) + (if before + (funcall (or yank-undo-function 'delete-region) (point) (mark t)) + (funcall (or yank-undo-function 'delete-region) (mark t) (point))) + (setq yank-undo-function nil) + (set-marker (mark-marker) (point) helm-current-buffer) + (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) + ;; Set the window start back where it was in the yank command, + ;; if possible. + (set-window-start (selected-window) yank-window-start t) + (when before + ;; This is like exchange-point-and-mark, but doesn't activate the mark. + ;; It is cleaner to avoid activation, even though the command + ;; loop would deactivate the mark because we inserted text. + (goto-char (prog1 (mark t) + (set-marker (mark-marker) (point) helm-current-buffer)))))) (kill-new str))) @@ -152,11 +152,11 @@ replace with STR as yanked string." (defun helm-mark-ring-get-candidates () (with-helm-current-buffer (cl-loop with marks = (if (mark t) (cons (mark-marker) mark-ring) mark-ring) - for i in marks - for m = (helm-mark-ring-get-marks i) - unless (and recip (member m recip)) - collect m into recip - finally return recip))) + for i in marks + for m = (helm-mark-ring-get-marks i) + unless (and recip (member m recip)) + collect m into recip + finally return recip))) (defvar helm-source-mark-ring '((name . "mark-ring") @@ -193,8 +193,8 @@ replace with STR as yanked string." (let (line) (if (string= "" line) (setq line "<EMPTY LINE>") - (setq line (car (split-string (thing-at-point 'line) - "[\n\r]")))) + (setq line (car (split-string (thing-at-point 'line) + "[\n\r]")))) (format "%7d:%s: %s" (line-number-at-pos) (marker-buffer marker) line)))) @@ -202,13 +202,13 @@ replace with STR as yanked string." (let ((marks global-mark-ring)) (when marks (cl-loop for i in marks - for gm = (unless (or (string-match - "^ " (format "%s" (marker-buffer i))) - (null (marker-buffer i))) - (helm-global-mark-ring-format-buffer i)) - when (and gm (not (member gm recip))) - collect gm into recip - finally return recip)))) + for gm = (unless (or (string-match + "^ " (format "%s" (marker-buffer i))) + (null (marker-buffer i))) + (helm-global-mark-ring-format-buffer i)) + when (and gm (not (member gm recip))) + collect gm into recip + finally return recip)))) ;;;; <Register> @@ -224,97 +224,97 @@ replace with STR as yanked string." (defun helm-register-candidates () "Collecting register contents and appropriate commands." (cl-loop for (char . val) in register-alist - for key = (single-key-description char) - for string-actions = - (cond - ((numberp val) - (list (int-to-string val) - 'insert-register - 'increment-register)) - ((markerp val) - (let ((buf (marker-buffer val))) - (if (null buf) - (list "a marker in no buffer") - (list (concat - "a buffer position:" - (buffer-name buf) - ", position " - (int-to-string (marker-position val))) - 'jump-to-register - 'insert-register)))) - ((and (consp val) (window-configuration-p (car val))) - (list "window configuration." - 'jump-to-register)) - ((and (consp val) (frame-configuration-p (car val))) - (list "frame configuration." - 'jump-to-register)) - ((and (consp val) (eq (car val) 'file)) - (list (concat "file:" - (prin1-to-string (cdr val)) - ".") - 'jump-to-register)) - ((and (consp val) (eq (car val) 'file-query)) - (list (concat "file:a file-query reference: file " - (car (cdr val)) - ", position " - (int-to-string (car (cdr (cdr val)))) - ".") - 'jump-to-register)) - ((consp val) - (let ((lines (format "%4d" (length val)))) - (list (format "%s: %s\n" lines - (truncate-string-to-width - (mapconcat 'identity (list (car val)) - "^J") (- (window-width) 15))) - 'insert-register))) - ((stringp val) - (list - ;; without properties - (concat (substring-no-properties - val 0 (min (length val) helm-register-max-offset)) - (if (> (length val) helm-register-max-offset) - "[...]" "")) - 'insert-register - 'append-to-register - 'prepend-to-register)) - ((vectorp val) - (list - "Undo-tree entry." - 'undo-tree-restore-state-from-register)) - (t - "GARBAGE!")) - collect (cons (format "Register %3s:\n %s" key (car string-actions)) - (cons char (cdr string-actions))))) + for key = (single-key-description char) + for string-actions = + (cond + ((numberp val) + (list (int-to-string val) + 'insert-register + 'increment-register)) + ((markerp val) + (let ((buf (marker-buffer val))) + (if (null buf) + (list "a marker in no buffer") + (list (concat + "a buffer position:" + (buffer-name buf) + ", position " + (int-to-string (marker-position val))) + 'jump-to-register + 'insert-register)))) + ((and (consp val) (window-configuration-p (car val))) + (list "window configuration." + 'jump-to-register)) + ((and (consp val) (frame-configuration-p (car val))) + (list "frame configuration." + 'jump-to-register)) + ((and (consp val) (eq (car val) 'file)) + (list (concat "file:" + (prin1-to-string (cdr val)) + ".") + 'jump-to-register)) + ((and (consp val) (eq (car val) 'file-query)) + (list (concat "file:a file-query reference: file " + (car (cdr val)) + ", position " + (int-to-string (car (cdr (cdr val)))) + ".") + 'jump-to-register)) + ((consp val) + (let ((lines (format "%4d" (length val)))) + (list (format "%s: %s\n" lines + (truncate-string-to-width + (mapconcat 'identity (list (car val)) + "^J") (- (window-width) 15))) + 'insert-register))) + ((stringp val) + (list + ;; without properties + (concat (substring-no-properties + val 0 (min (length val) helm-register-max-offset)) + (if (> (length val) helm-register-max-offset) + "[...]" "")) + 'insert-register + 'append-to-register + 'prepend-to-register)) + ((vectorp val) + (list + "Undo-tree entry." + 'undo-tree-restore-state-from-register)) + (t + "GARBAGE!")) + collect (cons (format "Register %3s:\n %s" key (car string-actions)) + (cons char (cdr string-actions))))) (defun helm-register-action-transformer (_actions register-and-functions) "Decide actions by the contents of register." (cl-loop with func-actions = - '((insert-register - "Insert Register" . - (lambda (c) (insert-register (car c)))) - (jump-to-register - "Jump to Register" . - (lambda (c) (jump-to-register (car c)))) - (append-to-register - "Append Region to Register" . - (lambda (c) (append-to-register - (car c) (region-beginning) (region-end)))) - (prepend-to-register - "Prepend Region to Register" . - (lambda (c) (prepend-to-register - (car c) (region-beginning) (region-end)))) - (increment-register - "Increment Prefix Arg to Register" . - (lambda (c) (increment-register - helm-current-prefix-arg (car c)))) - (undo-tree-restore-state-from-register - "Restore Undo-tree register" - (lambda (c) (and (fboundp 'undo-tree-restore-state-from-register) - (undo-tree-restore-state-from-register (car c)))))) - for func in (cdr register-and-functions) - for cell = (assq func func-actions) - when cell - collect (cdr cell))) + '((insert-register + "Insert Register" . + (lambda (c) (insert-register (car c)))) + (jump-to-register + "Jump to Register" . + (lambda (c) (jump-to-register (car c)))) + (append-to-register + "Append Region to Register" . + (lambda (c) (append-to-register + (car c) (region-beginning) (region-end)))) + (prepend-to-register + "Prepend Region to Register" . + (lambda (c) (prepend-to-register + (car c) (region-beginning) (region-end)))) + (increment-register + "Increment Prefix Arg to Register" . + (lambda (c) (increment-register + helm-current-prefix-arg (car c)))) + (undo-tree-restore-state-from-register + "Restore Undo-tree register" + (lambda (c) (and (fboundp 'undo-tree-restore-state-from-register) + (undo-tree-restore-state-from-register (car c)))))) + for func in (cdr register-and-functions) + for cell = (assq func func-actions) + when cell + collect (cdr cell))) ;;;###autoload (defun helm-mark-ring () |