diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2018-03-20 14:49:26 +0100 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2018-03-20 15:01:59 +0100 |
commit | 3999f3b8d91b341280b40f038ddb8d3cda0e2460 (patch) | |
tree | cc4c0b1370873b726490bb49c87062a35996f30a | |
parent | 4f121a564d345e80fe6485810ea464fd276ba5d5 (diff) |
Add touch action to HFF
* helm-files.el (helm-find-files-map): Bind it.
(helm-find-files-actions): Add it to action.
(helm-ff-touch-files): New, the action function.
(helm-ff-run-touch-files): New, the command.
* helm-help.el (helm-ff-help-message): Document command.
-rw-r--r-- | helm-files.el | 33 | ||||
-rw-r--r-- | helm-help.el | 21 |
2 files changed, 47 insertions, 7 deletions
diff --git a/helm-files.el b/helm-files.el index 3ab7ab65..4e290273 100644 --- a/helm-files.el +++ b/helm-files.el @@ -402,6 +402,7 @@ Of course you can also write your own function to do something else." (define-key map (kbd "M-H") 'helm-ff-run-hardlink-file) (define-key map (kbd "M-D") 'helm-ff-run-delete-file) (define-key map (kbd "M-K") 'helm-ff-run-kill-buffer-persistent) + (define-key map (kbd "M-T") 'helm-ff-run-touch-files) (define-key map (kbd "C-c d") 'helm-ff-persistent-delete) (define-key map (kbd "M-e") 'helm-ff-run-switch-to-eshell) (define-key map (kbd "C-c i") 'helm-ff-run-complete-fn-at-point) @@ -531,6 +532,7 @@ Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") "Ediff File `C-c ='" 'helm-find-files-ediff-files "Ediff Merge File `M-='" 'helm-find-files-ediff-merge-files "Delete File(s) `M-D'" 'helm-delete-marked-files + "Touch File(s) `M-T'" 'helm-ff-touch-files "Copy file(s) `M-C, C-u to follow'" 'helm-find-files-copy "Rename file(s) `M-R, C-u to follow'" 'helm-find-files-rename "Backup files" 'helm-find-files-backup @@ -978,6 +980,37 @@ prefix arg eshell buffer doesn't exists, create it and switch to it." (unless (get-buffer-process (current-buffer)) (funcall cd-eshell)))) +(defun helm-ff-touch-files (_candidate) + (let* ((files (helm-marked-candidates)) + (timestamp (helm-comp-read + "Timestamp (default Now): " + (cl-loop for f in files + for date = (format-time-string + "%Y-%m-%d %H:%M:%S" + (nth 5 (file-attributes f))) + collect (cons (format "%s: %s" + (helm-basename f) date) + date)) + :default + (format-time-string "%Y-%m-%d %H:%M:%S" + (current-time)))) + (failures + (cl-loop for f in files + when (> (call-process + "touch" nil nil nil "-d" timestamp f) + 0) + collect f))) + (when failures + (message "Failed to touch *%s files:\n%s" + (length failures) + (mapconcat (lambda (f) (format "- %s\n" f)) failures ""))))) + +(defun helm-ff-run-touch-files () + (interactive) + (with-helm-alive-p + (helm-exit-and-execute-action 'helm-ff-touch-files))) +(put 'helm-ff-run-touch-files 'helm-only t) + (defun helm-ff-serial-rename-action (method) "Rename all marked files in `helm-ff-default-directory' with METHOD. See `helm-ff-serial-rename-1'." diff --git a/helm-help.el b/helm-help.el index 73214712..234505c3 100644 --- a/helm-help.el +++ b/helm-help.el @@ -791,6 +791,12 @@ buffer is kept and files are displayed next to it. If you have mounted your filesystem with mountavfs, you can expand archives in the \"~/.avfs\" directory with \\<helm-map>\\[helm-execute-persistent-action]. +*** Touch files + +In the completion buffer, you can choose the default which is the current-time, it is +the first candidate or the timestamp of one of the selected files. +If you need to use something else, use \\<helm-map>\\[next-history-element] and edit +the date in minibuffer. ** Commands \\<helm-find-files-map> @@ -804,14 +810,15 @@ you can expand archives in the \"~/.avfs\" directory with \\<helm-map>\\[helm-ex \\[helm-ff-run-git-grep]\t\tRun git-grep on current directory. \\[helm-ff-run-gid]\t\tRun gid (id-utils). \\[helm-ff-run-etags]\t\tRun Etags (`\\[universal-argument]' to use thing-at-point, `\\[universal-argument] \\[universal-argument]' to reload cache). -\\[helm-ff-run-rename-file]\t\tRename File (`\\[universal-argument]' to follow). +\\[helm-ff-run-rename-file]\t\tRename Files (`\\[universal-argument]' to follow). \\[helm-ff-run-query-replace-fnames-on-marked]\t\tQuery replace on marked files. -\\[helm-ff-run-copy-file]\t\tCopy File (`\\[universal-argument]' to follow). -\\[helm-ff-run-byte-compile-file]\t\tByte Compile File (`\\[universal-argument]' to load). -\\[helm-ff-run-load-file]\t\tLoad File. -\\[helm-ff-run-symlink-file]\t\tSymlink File. -\\[helm-ff-run-hardlink-file]\t\tHardlink file. -\\[helm-ff-run-delete-file]\t\tDelete File. +\\[helm-ff-run-copy-file]\t\tCopy Files (`\\[universal-argument]' to follow). +\\[helm-ff-run-byte-compile-file]\t\tByte Compile Files (`\\[universal-argument]' to load). +\\[helm-ff-run-load-file]\t\tLoad Files. +\\[helm-ff-run-symlink-file]\t\tSymlink Files. +\\[helm-ff-run-hardlink-file]\t\tHardlink files. +\\[helm-ff-run-delete-file]\t\tDelete Files. +\\[helm-ff-run-touch-files]\t\tTouch files. \\[helm-ff-run-kill-buffer-persistent]\t\tKill buffer candidate without leaving Helm. \\[helm-ff-persistent-delete]\t\tDelete file without leaving Helm. \\[helm-ff-run-switch-to-eshell]\t\tSwitch to Eshell. |