comparison lisp/ibuf-ext.el @ 65896:7cc413612d3d

* ibuf-ext.el (ibuffer-do-shell-command-pipe) (ibuffer-do-shell-command-pipe-replace) (ibuffer-do-shell-command-file, ibuffer-do-eval) (ibuffer-do-view-and-eval, ibuffer-do-rename-uniquely) (ibuffer-do-revert, ibuffer-do-replace-regexp) (ibuffer-do-query-replace, ibuffer-do-query-replace-regexp) (ibuffer-do-print, ibuffer-filter-by-mode, ibuffer-filter-by-used-mode) (ibuffer-filter-by-name, ibuffer-filter-by-filename) (ibuffer-filter-by-size-gt, ibuffer-filter-by-size-lt) (ibuffer-filter-by-content, ibuffer-filter-by-predicate (ibuffer-do-sort-by-major-mode, ibuffer-do-sort-by-mode-name) (ibuffer-do-sort-by-alphabetic, ibuffer-do-sort-by-size): Autoload file sans suffix. * emulation/cua-base.el (cua-toggle-global-mark): Likewise.
author Romain Francoise <romain@orebokech.com>
date Fri, 07 Oct 2005 12:43:57 +0000
parents 6705c5e7dee2
children d94285b2b933 5e2d3828e89f
comparison
equal deleted inserted replaced
65895:1083f8e63cc0 65896:7cc413612d3d
327 (when (= (point) (point-min)) 327 (when (= (point) (point-min))
328 (goto-char (point-max)) 328 (goto-char (point-max))
329 (ibuffer-backward-filter-group 1)) 329 (ibuffer-backward-filter-group 1))
330 (ibuffer-forward-line 0)) 330 (ibuffer-forward-line 0))
331 331
332 ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext.el") 332 ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext")
333 (define-ibuffer-op shell-command-pipe (command) 333 (define-ibuffer-op shell-command-pipe (command)
334 "Pipe the contents of each marked buffer to shell command COMMAND." 334 "Pipe the contents of each marked buffer to shell command COMMAND."
335 (:interactive "sPipe to shell command: " 335 (:interactive "sPipe to shell command: "
336 :opstring "Shell command executed on" 336 :opstring "Shell command executed on"
337 :modifier-p nil) 337 :modifier-p nil)
338 (shell-command-on-region 338 (shell-command-on-region
339 (point-min) (point-max) command 339 (point-min) (point-max) command
340 (get-buffer-create "* ibuffer-shell-output*"))) 340 (get-buffer-create "* ibuffer-shell-output*")))
341 341
342 ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext.el") 342 ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext")
343 (define-ibuffer-op shell-command-pipe-replace (command) 343 (define-ibuffer-op shell-command-pipe-replace (command)
344 "Replace the contents of marked buffers with output of pipe to COMMAND." 344 "Replace the contents of marked buffers with output of pipe to COMMAND."
345 (:interactive "sPipe to shell command (replace): " 345 (:interactive "sPipe to shell command (replace): "
346 :opstring "Buffer contents replaced in" 346 :opstring "Buffer contents replaced in"
347 :active-opstring "replace buffer contents in" 347 :active-opstring "replace buffer contents in"
349 :modifier-p t) 349 :modifier-p t)
350 (with-current-buffer buf 350 (with-current-buffer buf
351 (shell-command-on-region (point-min) (point-max) 351 (shell-command-on-region (point-min) (point-max)
352 command nil t))) 352 command nil t)))
353 353
354 ;;;###autoload (autoload 'ibuffer-do-shell-command-file "ibuf-ext.el") 354 ;;;###autoload (autoload 'ibuffer-do-shell-command-file "ibuf-ext")
355 (define-ibuffer-op shell-command-file (command) 355 (define-ibuffer-op shell-command-file (command)
356 "Run shell command COMMAND separately on files of marked buffers." 356 "Run shell command COMMAND separately on files of marked buffers."
357 (:interactive "sShell command on buffer's file: " 357 (:interactive "sShell command on buffer's file: "
358 :opstring "Shell command executed on" 358 :opstring "Shell command executed on"
359 :modifier-p nil) 359 :modifier-p nil)
362 (if buffer-file-name 362 (if buffer-file-name
363 buffer-file-name 363 buffer-file-name
364 (make-temp-file 364 (make-temp-file
365 (substring (buffer-name) 0 (min 10 (length (buffer-name)))))))))) 365 (substring (buffer-name) 0 (min 10 (length (buffer-name))))))))))
366 366
367 ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext.el") 367 ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext")
368 (define-ibuffer-op eval (form) 368 (define-ibuffer-op eval (form)
369 "Evaluate FORM in each of the buffers. 369 "Evaluate FORM in each of the buffers.
370 Does not display the buffer during evaluation. See 370 Does not display the buffer during evaluation. See
371 `ibuffer-do-view-and-eval' for that." 371 `ibuffer-do-view-and-eval' for that."
372 (:interactive "xEval in buffers (form): " 372 (:interactive "xEval in buffers (form): "
373 :opstring "evaluated in" 373 :opstring "evaluated in"
374 :modifier-p :maybe) 374 :modifier-p :maybe)
375 (eval form)) 375 (eval form))
376 376
377 ;;;###autoload (autoload 'ibuffer-do-view-and-eval "ibuf-ext.el") 377 ;;;###autoload (autoload 'ibuffer-do-view-and-eval "ibuf-ext")
378 (define-ibuffer-op view-and-eval (form) 378 (define-ibuffer-op view-and-eval (form)
379 "Evaluate FORM while displaying each of the marked buffers. 379 "Evaluate FORM while displaying each of the marked buffers.
380 To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." 380 To evaluate a form without viewing the buffer, see `ibuffer-do-eval'."
381 (:interactive "xEval viewing buffers (form): " 381 (:interactive "xEval viewing buffers (form): "
382 :opstring "evaluated in" 382 :opstring "evaluated in"
387 (progn 387 (progn
388 (switch-to-buffer buf) 388 (switch-to-buffer buf)
389 (eval form)) 389 (eval form))
390 (switch-to-buffer ibuffer-buf)))) 390 (switch-to-buffer ibuffer-buf))))
391 391
392 ;;;###autoload (autoload 'ibuffer-do-rename-uniquely "ibuf-ext.el") 392 ;;;###autoload (autoload 'ibuffer-do-rename-uniquely "ibuf-ext")
393 (define-ibuffer-op rename-uniquely () 393 (define-ibuffer-op rename-uniquely ()
394 "Rename marked buffers as with `rename-uniquely'." 394 "Rename marked buffers as with `rename-uniquely'."
395 (:opstring "renamed" 395 (:opstring "renamed"
396 :modifier-p t) 396 :modifier-p t)
397 (rename-uniquely)) 397 (rename-uniquely))
398 398
399 ;;;###autoload (autoload 'ibuffer-do-revert "ibuf-ext.el") 399 ;;;###autoload (autoload 'ibuffer-do-revert "ibuf-ext")
400 (define-ibuffer-op revert () 400 (define-ibuffer-op revert ()
401 "Revert marked buffers as with `revert-buffer'." 401 "Revert marked buffers as with `revert-buffer'."
402 (:dangerous t 402 (:dangerous t
403 :opstring "reverted" 403 :opstring "reverted"
404 :active-opstring "revert" 404 :active-opstring "revert"
405 :modifier-p :maybe) 405 :modifier-p :maybe)
406 (revert-buffer t t)) 406 (revert-buffer t t))
407 407
408 ;;;###autoload (autoload 'ibuffer-do-replace-regexp "ibuf-ext.el") 408 ;;;###autoload (autoload 'ibuffer-do-replace-regexp "ibuf-ext")
409 (define-ibuffer-op replace-regexp (from-str to-str) 409 (define-ibuffer-op replace-regexp (from-str to-str)
410 "Perform a `replace-regexp' in marked buffers." 410 "Perform a `replace-regexp' in marked buffers."
411 (:interactive 411 (:interactive
412 (let* ((from-str (read-from-minibuffer "Replace regexp: ")) 412 (let* ((from-str (read-from-minibuffer "Replace regexp: "))
413 (to-str (read-from-minibuffer (concat "Replace " from-str 413 (to-str (read-from-minibuffer (concat "Replace " from-str
423 (let ((case-fold-search ibuffer-case-fold-search)) 423 (let ((case-fold-search ibuffer-case-fold-search))
424 (while (re-search-forward from-str nil t) 424 (while (re-search-forward from-str nil t)
425 (replace-match to-str)))) 425 (replace-match to-str))))
426 t)) 426 t))
427 427
428 ;;;###autoload (autoload 'ibuffer-do-query-replace "ibuf-ext.el") 428 ;;;###autoload (autoload 'ibuffer-do-query-replace "ibuf-ext")
429 (define-ibuffer-op query-replace (&rest args) 429 (define-ibuffer-op query-replace (&rest args)
430 "Perform a `query-replace' in marked buffers." 430 "Perform a `query-replace' in marked buffers."
431 (:interactive 431 (:interactive
432 (query-replace-read-args "Query replace" t t) 432 (query-replace-read-args "Query replace" t t)
433 :opstring "replaced in" 433 :opstring "replaced in"
439 (let ((case-fold-search ibuffer-case-fold-search)) 439 (let ((case-fold-search ibuffer-case-fold-search))
440 (goto-char (point-min)) 440 (goto-char (point-min))
441 (apply #'query-replace args))) 441 (apply #'query-replace args)))
442 t)) 442 t))
443 443
444 ;;;###autoload (autoload 'ibuffer-do-query-replace-regexp "ibuf-ext.el") 444 ;;;###autoload (autoload 'ibuffer-do-query-replace-regexp "ibuf-ext")
445 (define-ibuffer-op query-replace-regexp (&rest args) 445 (define-ibuffer-op query-replace-regexp (&rest args)
446 "Perform a `query-replace-regexp' in marked buffers." 446 "Perform a `query-replace-regexp' in marked buffers."
447 (:interactive 447 (:interactive
448 (query-replace-read-args "Query replace regexp" t t) 448 (query-replace-read-args "Query replace regexp" t t)
449 :opstring "replaced in" 449 :opstring "replaced in"
455 (let ((case-fold-search ibuffer-case-fold-search)) 455 (let ((case-fold-search ibuffer-case-fold-search))
456 (goto-char (point-min)) 456 (goto-char (point-min))
457 (apply #'query-replace-regexp args))) 457 (apply #'query-replace-regexp args)))
458 t)) 458 t))
459 459
460 ;;;###autoload (autoload 'ibuffer-do-print "ibuf-ext.el") 460 ;;;###autoload (autoload 'ibuffer-do-print "ibuf-ext")
461 (define-ibuffer-op print () 461 (define-ibuffer-op print ()
462 "Print marked buffers as with `print-buffer'." 462 "Print marked buffers as with `print-buffer'."
463 (:opstring "printed" 463 (:opstring "printed"
464 :modifier-p nil) 464 :modifier-p nil)
465 (print-buffer)) 465 (print-buffer))
967 modes)) 967 modes))
968 968
969 969
970 ;;; Extra operation definitions 970 ;;; Extra operation definitions
971 971
972 ;;;###autoload (autoload 'ibuffer-filter-by-mode "ibuf-ext.el") 972 ;;;###autoload (autoload 'ibuffer-filter-by-mode "ibuf-ext")
973 (define-ibuffer-filter mode 973 (define-ibuffer-filter mode
974 "Toggle current view to buffers with major mode QUALIFIER." 974 "Toggle current view to buffers with major mode QUALIFIER."
975 (:description "major mode" 975 (:description "major mode"
976 :reader 976 :reader
977 (intern 977 (intern
985 (with-current-buffer buf 985 (with-current-buffer buf
986 (symbol-name major-mode)) 986 (symbol-name major-mode))
987 ""))))) 987 "")))))
988 (eq qualifier (with-current-buffer buf major-mode))) 988 (eq qualifier (with-current-buffer buf major-mode)))
989 989
990 ;;;###autoload (autoload 'ibuffer-filter-by-used-mode "ibuf-ext.el") 990 ;;;###autoload (autoload 'ibuffer-filter-by-used-mode "ibuf-ext")
991 (define-ibuffer-filter used-mode 991 (define-ibuffer-filter used-mode
992 "Toggle current view to buffers with major mode QUALIFIER. 992 "Toggle current view to buffers with major mode QUALIFIER.
993 Called interactively, this function allows selection of modes 993 Called interactively, this function allows selection of modes
994 currently used by buffers." 994 currently used by buffers."
995 (:description "major mode in use" 995 (:description "major mode in use"
1004 (with-current-buffer buf 1004 (with-current-buffer buf
1005 (symbol-name major-mode)) 1005 (symbol-name major-mode))
1006 ""))))) 1006 "")))))
1007 (eq qualifier (with-current-buffer buf major-mode))) 1007 (eq qualifier (with-current-buffer buf major-mode)))
1008 1008
1009 ;;;###autoload (autoload 'ibuffer-filter-by-name "ibuf-ext.el") 1009 ;;;###autoload (autoload 'ibuffer-filter-by-name "ibuf-ext")
1010 (define-ibuffer-filter name 1010 (define-ibuffer-filter name
1011 "Toggle current view to buffers with name matching QUALIFIER." 1011 "Toggle current view to buffers with name matching QUALIFIER."
1012 (:description "buffer name" 1012 (:description "buffer name"
1013 :reader (read-from-minibuffer "Filter by name (regexp): ")) 1013 :reader (read-from-minibuffer "Filter by name (regexp): "))
1014 (string-match qualifier (buffer-name buf))) 1014 (string-match qualifier (buffer-name buf)))
1015 1015
1016 ;;;###autoload (autoload 'ibuffer-filter-by-filename "ibuf-ext.el") 1016 ;;;###autoload (autoload 'ibuffer-filter-by-filename "ibuf-ext")
1017 (define-ibuffer-filter filename 1017 (define-ibuffer-filter filename
1018 "Toggle current view to buffers with filename matching QUALIFIER." 1018 "Toggle current view to buffers with filename matching QUALIFIER."
1019 (:description "filename" 1019 (:description "filename"
1020 :reader (read-from-minibuffer "Filter by filename (regexp): ")) 1020 :reader (read-from-minibuffer "Filter by filename (regexp): "))
1021 (ibuffer-awhen (with-current-buffer buf 1021 (ibuffer-awhen (with-current-buffer buf
1025 dired-directory 1025 dired-directory
1026 (car dired-directory)) 1026 (car dired-directory))
1027 (expand-file-name dired-directory)))) 1027 (expand-file-name dired-directory))))
1028 (string-match qualifier it))) 1028 (string-match qualifier it)))
1029 1029
1030 ;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext.el") 1030 ;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext")
1031 (define-ibuffer-filter size-gt 1031 (define-ibuffer-filter size-gt
1032 "Toggle current view to buffers with size greater than QUALIFIER." 1032 "Toggle current view to buffers with size greater than QUALIFIER."
1033 (:description "size greater than" 1033 (:description "size greater than"
1034 :reader 1034 :reader
1035 (string-to-number (read-from-minibuffer "Filter by size greater than: "))) 1035 (string-to-number (read-from-minibuffer "Filter by size greater than: ")))
1036 (> (with-current-buffer buf (buffer-size)) 1036 (> (with-current-buffer buf (buffer-size))
1037 qualifier)) 1037 qualifier))
1038 1038
1039 ;;;###autoload (autoload 'ibuffer-filter-by-size-lt "ibuf-ext.el") 1039 ;;;###autoload (autoload 'ibuffer-filter-by-size-lt "ibuf-ext")
1040 (define-ibuffer-filter size-lt 1040 (define-ibuffer-filter size-lt
1041 "Toggle current view to buffers with size less than QUALIFIER." 1041 "Toggle current view to buffers with size less than QUALIFIER."
1042 (:description "size less than" 1042 (:description "size less than"
1043 :reader 1043 :reader
1044 (string-to-number (read-from-minibuffer "Filter by size less than: "))) 1044 (string-to-number (read-from-minibuffer "Filter by size less than: ")))
1045 (< (with-current-buffer buf (buffer-size)) 1045 (< (with-current-buffer buf (buffer-size))
1046 qualifier)) 1046 qualifier))
1047 1047
1048 ;;;###autoload (autoload 'ibuffer-filter-by-content "ibuf-ext.el") 1048 ;;;###autoload (autoload 'ibuffer-filter-by-content "ibuf-ext")
1049 (define-ibuffer-filter content 1049 (define-ibuffer-filter content
1050 "Toggle current view to buffers whose contents match QUALIFIER." 1050 "Toggle current view to buffers whose contents match QUALIFIER."
1051 (:description "content" 1051 (:description "content"
1052 :reader (read-from-minibuffer "Filter by content (regexp): ")) 1052 :reader (read-from-minibuffer "Filter by content (regexp): "))
1053 (with-current-buffer buf 1053 (with-current-buffer buf
1054 (save-excursion 1054 (save-excursion
1055 (goto-char (point-min)) 1055 (goto-char (point-min))
1056 (re-search-forward qualifier nil t)))) 1056 (re-search-forward qualifier nil t))))
1057 1057
1058 ;;;###autoload (autoload 'ibuffer-filter-by-predicate "ibuf-ext.el") 1058 ;;;###autoload (autoload 'ibuffer-filter-by-predicate "ibuf-ext")
1059 (define-ibuffer-filter predicate 1059 (define-ibuffer-filter predicate
1060 "Toggle current view to buffers for which QUALIFIER returns non-nil." 1060 "Toggle current view to buffers for which QUALIFIER returns non-nil."
1061 (:description "predicate" 1061 (:description "predicate"
1062 :reader (read-minibuffer "Filter by predicate (form): ")) 1062 :reader (read-minibuffer "Filter by predicate (form): "))
1063 (with-current-buffer buf 1063 (with-current-buffer buf
1092 (if ibuffer-sorting-reversep 1092 (if ibuffer-sorting-reversep
1093 "reversed" 1093 "reversed"
1094 "normal")) 1094 "normal"))
1095 (ibuffer-redisplay t)) 1095 (ibuffer-redisplay t))
1096 1096
1097 ;;;###autoload (autoload 'ibuffer-do-sort-by-major-mode "ibuf-ext.el") 1097 ;;;###autoload (autoload 'ibuffer-do-sort-by-major-mode "ibuf-ext")
1098 (define-ibuffer-sorter major-mode 1098 (define-ibuffer-sorter major-mode
1099 "Sort the buffers by major modes. 1099 "Sort the buffers by major modes.
1100 Ordering is lexicographic." 1100 Ordering is lexicographic."
1101 (:description "major mode") 1101 (:description "major mode")
1102 (string-lessp (downcase 1102 (string-lessp (downcase
1106 (downcase 1106 (downcase
1107 (symbol-name (with-current-buffer 1107 (symbol-name (with-current-buffer
1108 (car b) 1108 (car b)
1109 major-mode))))) 1109 major-mode)))))
1110 1110
1111 ;;;###autoload (autoload 'ibuffer-do-sort-by-mode-name "ibuf-ext.el") 1111 ;;;###autoload (autoload 'ibuffer-do-sort-by-mode-name "ibuf-ext")
1112 (define-ibuffer-sorter mode-name 1112 (define-ibuffer-sorter mode-name
1113 "Sort the buffers by their mode name. 1113 "Sort the buffers by their mode name.
1114 Ordering is lexicographic." 1114 Ordering is lexicographic."
1115 (:description "major mode name") 1115 (:description "major mode name")
1116 (string-lessp (downcase 1116 (string-lessp (downcase
1120 (downcase 1120 (downcase
1121 (with-current-buffer 1121 (with-current-buffer
1122 (car b) 1122 (car b)
1123 mode-name)))) 1123 mode-name))))
1124 1124
1125 ;;;###autoload (autoload 'ibuffer-do-sort-by-alphabetic "ibuf-ext.el") 1125 ;;;###autoload (autoload 'ibuffer-do-sort-by-alphabetic "ibuf-ext")
1126 (define-ibuffer-sorter alphabetic 1126 (define-ibuffer-sorter alphabetic
1127 "Sort the buffers by their names. 1127 "Sort the buffers by their names.
1128 Ordering is lexicographic." 1128 Ordering is lexicographic."
1129 (:description "buffer name") 1129 (:description "buffer name")
1130 (string-lessp 1130 (string-lessp
1131 (buffer-name (car a)) 1131 (buffer-name (car a))
1132 (buffer-name (car b)))) 1132 (buffer-name (car b))))
1133 1133
1134 ;;;###autoload (autoload 'ibuffer-do-sort-by-size "ibuf-ext.el") 1134 ;;;###autoload (autoload 'ibuffer-do-sort-by-size "ibuf-ext")
1135 (define-ibuffer-sorter size 1135 (define-ibuffer-sorter size
1136 "Sort the buffers by their size." 1136 "Sort the buffers by their size."
1137 (:description "size") 1137 (:description "size")
1138 (< (with-current-buffer (car a) 1138 (< (with-current-buffer (car a)
1139 (buffer-size)) 1139 (buffer-size))