em-pred.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. ;;; em-pred.el --- argument predicates and modifiers (ala zsh) -*- lexical-binding:t -*-
  2. ;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. ;; Author: John Wiegley <johnw@gnu.org>
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;; Argument predication is used to affect which members of a list are
  17. ;; selected for use as argument. This is most useful with globbing,
  18. ;; but can be used on any list argument, to select certain members.
  19. ;;
  20. ;; Argument modifiers are used to manipulate argument values. For
  21. ;; example, sorting lists, upcasing words, substituting characters,
  22. ;; etc.
  23. ;;
  24. ;; Here are some examples of how to use argument predication. Most of
  25. ;; the predicates and modifiers are modeled after those provided by
  26. ;; zsh.
  27. ;;
  28. ;; ls -ld *(/) ; list all directories
  29. ;; ls -l *(@u'johnw') ; list all symlinks owned by 'johnw'
  30. ;; bzip2 -9v **/*(a+30) ; compress everything which hasn't been
  31. ;; accessed in 30 days
  32. ;; echo *.c(:o:R) ; a reversed, sorted list of C files
  33. ;; *(^@:U^u0) ; all non-symlinks not owned by 'root', upcased
  34. ;; chmod u-x *(U*) : remove exec bit on all executables owned by user
  35. ;;
  36. ;; See the zsh docs for more on the syntax ([(zsh.info)Filename
  37. ;; Generation]).
  38. ;;; Code:
  39. (require 'esh-util)
  40. (require 'esh-arg)
  41. (eval-when-compile (require 'eshell))
  42. ;;;###autoload
  43. (progn
  44. (defgroup eshell-pred nil
  45. "This module allows for predicates to be applied to globbing
  46. patterns (similar to zsh), in addition to string modifiers which can
  47. be applied either to globbing results, variable references, or just
  48. ordinary strings."
  49. :tag "Value modifiers and predicates"
  50. :group 'eshell-module))
  51. ;;; User Variables:
  52. (defcustom eshell-pred-load-hook nil
  53. "A list of functions to run when `eshell-pred' is loaded."
  54. :version "24.1" ; removed eshell-pred-initialize
  55. :type 'hook
  56. :group 'eshell-pred)
  57. (defcustom eshell-predicate-alist
  58. '((?/ . (eshell-pred-file-type ?d)) ; directories
  59. (?. . (eshell-pred-file-type ?-)) ; regular files
  60. (?s . (eshell-pred-file-type ?s)) ; sockets
  61. (?p . (eshell-pred-file-type ?p)) ; named pipes
  62. (?@ . (eshell-pred-file-type ?l)) ; symbolic links
  63. (?% . (eshell-pred-file-type ?%)) ; allow user to specify (c def.)
  64. (?r . (eshell-pred-file-mode 0400)) ; owner-readable
  65. (?w . (eshell-pred-file-mode 0200)) ; owner-writable
  66. (?x . (eshell-pred-file-mode 0100)) ; owner-executable
  67. (?A . (eshell-pred-file-mode 0040)) ; group-readable
  68. (?I . (eshell-pred-file-mode 0020)) ; group-writable
  69. (?E . (eshell-pred-file-mode 0010)) ; group-executable
  70. (?R . (eshell-pred-file-mode 0004)) ; world-readable
  71. (?W . (eshell-pred-file-mode 0002)) ; world-writable
  72. (?X . (eshell-pred-file-mode 0001)) ; world-executable
  73. (?s . (eshell-pred-file-mode 4000)) ; setuid
  74. (?S . (eshell-pred-file-mode 2000)) ; setgid
  75. (?t . (eshell-pred-file-mode 1000)) ; sticky bit
  76. (?U . #'(lambda (file) ; owned by effective uid
  77. (if (file-exists-p file)
  78. (= (nth 2 (file-attributes file)) (user-uid)))))
  79. ;; (?G . #'(lambda (file) ; owned by effective gid
  80. ;; (if (file-exists-p file)
  81. ;; (= (nth 2 (file-attributes file)) (user-uid)))))
  82. (?* . #'(lambda (file)
  83. (and (file-regular-p file)
  84. (not (file-symlink-p file))
  85. (file-executable-p file))))
  86. (?l . (eshell-pred-file-links))
  87. (?u . (eshell-pred-user-or-group ?u "user" 2 'eshell-user-id))
  88. (?g . (eshell-pred-user-or-group ?g "group" 3 'eshell-group-id))
  89. (?a . (eshell-pred-file-time ?a "access" 4))
  90. (?m . (eshell-pred-file-time ?m "modification" 5))
  91. (?c . (eshell-pred-file-time ?c "change" 6))
  92. (?L . (eshell-pred-file-size)))
  93. "A list of predicates than can be applied to a globbing pattern.
  94. The format of each entry is
  95. (CHAR . PREDICATE-FUNC-SEXP)"
  96. :type '(repeat (cons character sexp))
  97. :group 'eshell-pred)
  98. (put 'eshell-predicate-alist 'risky-local-variable t)
  99. (defcustom eshell-modifier-alist
  100. '((?E . #'(lambda (lst)
  101. (mapcar
  102. (function
  103. (lambda (str)
  104. (eshell-stringify
  105. (car (eshell-parse-argument str)))))
  106. lst)))
  107. (?L . #'(lambda (lst) (mapcar 'downcase lst)))
  108. (?U . #'(lambda (lst) (mapcar 'upcase lst)))
  109. (?C . #'(lambda (lst) (mapcar 'capitalize lst)))
  110. (?h . #'(lambda (lst) (mapcar 'file-name-directory lst)))
  111. (?i . (eshell-include-members))
  112. (?x . (eshell-include-members t))
  113. (?r . #'(lambda (lst) (mapcar 'file-name-sans-extension lst)))
  114. (?e . #'(lambda (lst) (mapcar 'file-name-extension lst)))
  115. (?t . #'(lambda (lst) (mapcar 'file-name-nondirectory lst)))
  116. (?q . #'(lambda (lst) (mapcar 'eshell-escape-arg lst)))
  117. (?u . #'(lambda (lst) (eshell-uniqify-list lst)))
  118. (?o . #'(lambda (lst) (sort lst 'string-lessp)))
  119. (?O . #'(lambda (lst) (nreverse (sort lst 'string-lessp))))
  120. (?j . (eshell-join-members))
  121. (?S . (eshell-split-members))
  122. (?R . 'reverse)
  123. (?g . (progn
  124. (forward-char)
  125. (if (eq (char-before) ?s)
  126. (eshell-pred-substitute t)
  127. (error "`g' modifier cannot be used alone"))))
  128. (?s . (eshell-pred-substitute)))
  129. "A list of modifiers than can be applied to an argument expansion.
  130. The format of each entry is
  131. (CHAR ENTRYWISE-P MODIFIER-FUNC-SEXP)"
  132. :type '(repeat (cons character sexp))
  133. :group 'eshell-pred)
  134. (put 'eshell-modifier-alist 'risky-local-variable t)
  135. (defvar eshell-predicate-help-string
  136. "Eshell predicate quick reference:
  137. - follow symbolic references for predicates after the `-'
  138. ^ invert sense of predicates after the `^'
  139. FILE TYPE:
  140. / directories s sockets
  141. . regular files p named pipes
  142. * executable (files only) @ symbolic links
  143. %x file type == `x' (as by ls -l; so `c' = char device, etc.)
  144. PERMISSION BITS (for owner/group/world):
  145. r/A/R readable s setuid
  146. w/I/W writable S setgid
  147. x/E/X executable t sticky bit
  148. OWNERSHIP:
  149. U owned by effective uid
  150. u(UID|\\='user\\=') owned by UID/user
  151. g(GID|\\='group\\=') owned by GID/group
  152. FILE ATTRIBUTES:
  153. l[+-]N +/-/= N links
  154. a[Mwhms][+-](N|\\='FILE\\=') access time +/-/= N months/weeks/hours/mins/secs
  155. (days if unspecified) if FILE specified,
  156. use as comparison basis; so a+\\='file.c\\='
  157. shows files accessed before file.c was
  158. last accessed
  159. m[Mwhms][+-](N|\\='FILE\\=') modification time...
  160. c[Mwhms][+-](N|\\='FILE\\=') change time...
  161. L[kmp][+-]N file size +/-/= N Kb/Mb/blocks
  162. EXAMPLES:
  163. *(^@) all non-dot files which are not symlinks
  164. .#*(^@) all files which are not symbolic links
  165. **/.#*(*) all executable files, searched recursively
  166. ***/*~f*(-/) recursively (though not traversing symlinks),
  167. find all directories (or symlinks referring to
  168. directories) whose names do not begin with f.
  169. e*(*Lk+50) executables 50k or larger beginning with `e'")
  170. (defvar eshell-modifier-help-string
  171. "Eshell modifier quick reference:
  172. FOR SINGLE ARGUMENTS, or each argument of a list of strings:
  173. E evaluate again
  174. L lowercase
  175. U uppercase
  176. C capitalize
  177. h dirname
  178. t basename
  179. e file extension
  180. r strip file extension
  181. q escape special characters
  182. S split string at any whitespace character
  183. S/PAT/ split string at each occurrence of PAT
  184. FOR LISTS OF ARGUMENTS:
  185. o sort alphabetically
  186. O reverse sort alphabetically
  187. u uniq list (typically used after :o or :O)
  188. R reverse list
  189. j join list members, separated by a space
  190. j/PAT/ join list members, separated by PAT
  191. i/PAT/ exclude all members not matching PAT
  192. x/PAT/ exclude all members matching PAT
  193. s/pat/match/ substitute PAT with MATCH
  194. g/pat/match/ substitute PAT with MATCH for all occurrences
  195. EXAMPLES:
  196. *.c(:o) sorted list of .c files")
  197. ;;; Functions:
  198. (defun eshell-display-predicate-help ()
  199. (interactive)
  200. (with-electric-help
  201. (function
  202. (lambda ()
  203. (insert eshell-predicate-help-string)))))
  204. (defun eshell-display-modifier-help ()
  205. (interactive)
  206. (with-electric-help
  207. (function
  208. (lambda ()
  209. (insert eshell-modifier-help-string)))))
  210. (defun eshell-pred-initialize ()
  211. "Initialize the predicate/modifier code."
  212. (add-hook 'eshell-parse-argument-hook
  213. 'eshell-parse-arg-modifier t t)
  214. (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help)
  215. (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help))
  216. (defun eshell-apply-modifiers (lst predicates modifiers)
  217. "Apply to LIST a series of PREDICATES and MODIFIERS."
  218. (let (stringified)
  219. (if (stringp lst)
  220. (setq lst (list lst)
  221. stringified t))
  222. (when (listp lst)
  223. (setq lst (eshell-winnow-list lst nil predicates))
  224. (while modifiers
  225. (setq lst (funcall (car modifiers) lst)
  226. modifiers (cdr modifiers)))
  227. (if (and stringified
  228. (= (length lst) 1))
  229. (car lst)
  230. lst))))
  231. (defun eshell-parse-arg-modifier ()
  232. "Parse a modifier that has been specified after an argument.
  233. This function is specially for adding onto `eshell-parse-argument-hook'."
  234. (when (eq (char-after) ?\()
  235. (forward-char)
  236. (let ((end (eshell-find-delimiter ?\( ?\))))
  237. (if (not end)
  238. (throw 'eshell-incomplete ?\()
  239. (when (eshell-arg-delimiter (1+ end))
  240. (save-restriction
  241. (narrow-to-region (point) end)
  242. (let* ((modifiers (eshell-parse-modifiers))
  243. (preds (car modifiers))
  244. (mods (cdr modifiers)))
  245. (if (or preds mods)
  246. ;; has to go at the end, which is only natural since
  247. ;; syntactically it can only occur at the end
  248. (setq eshell-current-modifiers
  249. (append
  250. eshell-current-modifiers
  251. (list
  252. `(lambda (lst)
  253. (eshell-apply-modifiers
  254. lst (quote ,preds) (quote ,mods)))))))))
  255. (goto-char (1+ end))
  256. (eshell-finish-arg))))))
  257. (defun eshell-parse-modifiers ()
  258. "Parse value modifiers and predicates at point.
  259. Return a cons cell of the form
  260. (PRED-FUNC-LIST . MOD-FUNC-LIST)
  261. PRED-FUNC-LIST is a list of predicate functions. MOD-FUNC-LIST
  262. is a list of result modifier functions. PRED-FUNCS take a
  263. filename and return t if the test succeeds; MOD-FUNCS take any
  264. list of strings and perform a modification, returning the
  265. resultant list of strings."
  266. (let (negate follow preds mods)
  267. (condition-case nil
  268. (while (not (eobp))
  269. (let ((char (char-after)))
  270. (cond
  271. ((eq char ?')
  272. (forward-char)
  273. (if (looking-at "[^|':]")
  274. (let ((func (read (current-buffer))))
  275. (if (and func (functionp func))
  276. (setq preds (eshell-add-pred-func func preds
  277. negate follow))
  278. (error "Invalid function predicate `%s'"
  279. (eshell-stringify func))))
  280. (error "Invalid function predicate")))
  281. ((eq char ?^)
  282. (forward-char)
  283. (setq negate (not negate)))
  284. ((eq char ?-)
  285. (forward-char)
  286. (setq follow (not follow)))
  287. ((eq char ?|)
  288. (forward-char)
  289. (if (looking-at "[^|':]")
  290. (let ((func (read (current-buffer))))
  291. (if (and func (functionp func))
  292. (setq mods
  293. (cons `(lambda (lst)
  294. (mapcar (function ,func) lst))
  295. mods))
  296. (error "Invalid function modifier `%s'"
  297. (eshell-stringify func))))
  298. (error "Invalid function modifier")))
  299. ((eq char ?:)
  300. (forward-char)
  301. (let ((mod (assq (char-after) eshell-modifier-alist)))
  302. (if (not mod)
  303. (error "Unknown modifier character `%c'" (char-after))
  304. (forward-char)
  305. (setq mods (cons (eval (cdr mod)) mods)))))
  306. (t
  307. (let ((pred (assq char eshell-predicate-alist)))
  308. (if (not pred)
  309. (error "Unknown predicate character `%c'" char)
  310. (forward-char)
  311. (setq preds
  312. (eshell-add-pred-func (eval (cdr pred)) preds
  313. negate follow))))))))
  314. (end-of-buffer
  315. (error "Predicate or modifier ended prematurely")))
  316. (cons (nreverse preds) (nreverse mods))))
  317. (defun eshell-add-pred-func (pred funcs negate follow)
  318. "Add the predicate function PRED to FUNCS."
  319. (if negate
  320. (setq pred `(lambda (file)
  321. (not (funcall ,pred file)))))
  322. (if follow
  323. (setq pred `(lambda (file)
  324. (funcall ,pred (file-truename file)))))
  325. (cons pred funcs))
  326. (defun eshell-pred-user-or-group (mod-char mod-type attr-index get-id-func)
  327. "Return a predicate to test whether a file match a given user/group id."
  328. (let (ugid open close end)
  329. (if (looking-at "[0-9]+")
  330. (progn
  331. (setq ugid (string-to-number (match-string 0)))
  332. (goto-char (match-end 0)))
  333. (setq open (char-after))
  334. (if (setq close (memq open '(?\( ?\[ ?\< ?\{)))
  335. (setq close (car (last '(?\) ?\] ?\> ?\})
  336. (length close))))
  337. (setq close open))
  338. (forward-char)
  339. (setq end (eshell-find-delimiter open close))
  340. (unless end
  341. (error "Malformed %s name string for modifier `%c'"
  342. mod-type mod-char))
  343. (setq ugid
  344. (funcall get-id-func (buffer-substring (point) end)))
  345. (goto-char (1+ end)))
  346. (unless ugid
  347. (error "Unknown %s name specified for modifier `%c'"
  348. mod-type mod-char))
  349. `(lambda (file)
  350. (let ((attrs (file-attributes file)))
  351. (if attrs
  352. (= (nth ,attr-index attrs) ,ugid))))))
  353. (defun eshell-pred-file-time (mod-char mod-type attr-index)
  354. "Return a predicate to test whether a file matches a certain time."
  355. (let* ((quantum 86400)
  356. qual when open close end)
  357. (when (memq (char-after) '(?M ?w ?h ?m ?s))
  358. (setq quantum (char-after))
  359. (cond
  360. ((eq quantum ?M)
  361. (setq quantum (* 60 60 24 30)))
  362. ((eq quantum ?w)
  363. (setq quantum (* 60 60 24 7)))
  364. ((eq quantum ?h)
  365. (setq quantum (* 60 60)))
  366. ((eq quantum ?m)
  367. (setq quantum 60))
  368. ((eq quantum ?s)
  369. (setq quantum 1)))
  370. (forward-char))
  371. (when (memq (char-after) '(?+ ?-))
  372. (setq qual (char-after))
  373. (forward-char))
  374. (if (looking-at "[0-9]+")
  375. (progn
  376. (setq when (- (float-time)
  377. (* (string-to-number (match-string 0))
  378. quantum)))
  379. (goto-char (match-end 0)))
  380. (setq open (char-after))
  381. (if (setq close (memq open '(?\( ?\[ ?\< ?\{)))
  382. (setq close (car (last '(?\) ?\] ?\> ?\})
  383. (length close))))
  384. (setq close open))
  385. (forward-char)
  386. (setq end (eshell-find-delimiter open close))
  387. (unless end
  388. (error "Malformed %s time modifier `%c'" mod-type mod-char))
  389. (let* ((file (buffer-substring (point) end))
  390. (attrs (file-attributes file)))
  391. (unless attrs
  392. (error "Cannot stat file `%s'" file))
  393. (setq when (float-time (nth attr-index attrs))))
  394. (goto-char (1+ end)))
  395. `(lambda (file)
  396. (let ((attrs (file-attributes file)))
  397. (if attrs
  398. (,(if (eq qual ?-)
  399. '<
  400. (if (eq qual ?+)
  401. '>
  402. '=)) ,when (float-time
  403. (nth ,attr-index attrs))))))))
  404. (defun eshell-pred-file-type (type)
  405. "Return a test which tests that the file is of a certain TYPE.
  406. TYPE must be a character, and should be one of the possible options
  407. that `ls -l' will show in the first column of its display. "
  408. (when (eq type ?%)
  409. (setq type (char-after))
  410. (if (memq type '(?b ?c))
  411. (forward-char)
  412. (setq type ?%)))
  413. `(lambda (file)
  414. (let ((attrs (eshell-file-attributes (directory-file-name file))))
  415. (if attrs
  416. (memq (aref (nth 8 attrs) 0)
  417. ,(if (eq type ?%)
  418. '(?b ?c)
  419. (list 'quote (list type))))))))
  420. (defsubst eshell-pred-file-mode (mode)
  421. "Return a test which tests that MODE pertains to the file."
  422. `(lambda (file)
  423. (let ((modes (file-modes file)))
  424. (if modes
  425. (logand ,mode modes)))))
  426. (defun eshell-pred-file-links ()
  427. "Return a predicate to test whether a file has a given number of links."
  428. (let (qual amount)
  429. (when (memq (char-after) '(?- ?+))
  430. (setq qual (char-after))
  431. (forward-char))
  432. (unless (looking-at "[0-9]+")
  433. (error "Invalid file link count modifier `l'"))
  434. (setq amount (string-to-number (match-string 0)))
  435. (goto-char (match-end 0))
  436. `(lambda (file)
  437. (let ((attrs (eshell-file-attributes file)))
  438. (if attrs
  439. (,(if (eq qual ?-)
  440. '<
  441. (if (eq qual ?+)
  442. '>
  443. '=)) (nth 1 attrs) ,amount))))))
  444. (defun eshell-pred-file-size ()
  445. "Return a predicate to test whether a file is of a given size."
  446. (let ((quantum 1) qual amount)
  447. (when (memq (downcase (char-after)) '(?k ?m ?p))
  448. (setq qual (downcase (char-after)))
  449. (cond
  450. ((eq qual ?k)
  451. (setq quantum 1024))
  452. ((eq qual ?m)
  453. (setq quantum (* 1024 1024)))
  454. ((eq qual ?p)
  455. (setq quantum 512)))
  456. (forward-char))
  457. (when (memq (char-after) '(?- ?+))
  458. (setq qual (char-after))
  459. (forward-char))
  460. (unless (looking-at "[0-9]+")
  461. (error "Invalid file size modifier `L'"))
  462. (setq amount (* (string-to-number (match-string 0)) quantum))
  463. (goto-char (match-end 0))
  464. `(lambda (file)
  465. (let ((attrs (eshell-file-attributes file)))
  466. (if attrs
  467. (,(if (eq qual ?-)
  468. '<
  469. (if (eq qual ?+)
  470. '>
  471. '=)) (nth 7 attrs) ,amount))))))
  472. (defun eshell-pred-substitute (&optional repeat)
  473. "Return a modifier function that will substitute matches."
  474. (let ((delim (char-after))
  475. match replace end)
  476. (forward-char)
  477. (setq end (eshell-find-delimiter delim delim nil nil t)
  478. match (buffer-substring-no-properties (point) end))
  479. (goto-char (1+ end))
  480. (setq end (eshell-find-delimiter delim delim nil nil t)
  481. replace (buffer-substring-no-properties (point) end))
  482. (goto-char (1+ end))
  483. (if repeat
  484. `(lambda (lst)
  485. (mapcar
  486. (function
  487. (lambda (str)
  488. (let ((i 0))
  489. (while (setq i (string-match ,match str i))
  490. (setq str (replace-match ,replace t nil str))))
  491. str)) lst))
  492. `(lambda (lst)
  493. (mapcar
  494. (function
  495. (lambda (str)
  496. (if (string-match ,match str)
  497. (setq str (replace-match ,replace t nil str)))
  498. str)) lst)))))
  499. (defun eshell-include-members (&optional invert-p)
  500. "Include only lisp members matching a regexp."
  501. (let ((delim (char-after))
  502. regexp end)
  503. (forward-char)
  504. (setq end (eshell-find-delimiter delim delim nil nil t)
  505. regexp (buffer-substring-no-properties (point) end))
  506. (goto-char (1+ end))
  507. `(lambda (lst)
  508. (eshell-winnow-list
  509. lst nil '((lambda (elem)
  510. ,(if invert-p
  511. `(not (string-match ,regexp elem))
  512. `(string-match ,regexp elem))))))))
  513. (defun eshell-join-members ()
  514. "Return a modifier function that join matches."
  515. (let ((delim (char-after))
  516. str end)
  517. (if (not (memq delim '(?' ?/)))
  518. (setq delim " ")
  519. (forward-char)
  520. (setq end (eshell-find-delimiter delim delim nil nil t)
  521. str (buffer-substring-no-properties (point) end))
  522. (goto-char (1+ end)))
  523. `(lambda (lst)
  524. (mapconcat 'identity lst ,str))))
  525. (defun eshell-split-members ()
  526. "Return a modifier function that splits members."
  527. (let ((delim (char-after))
  528. sep end)
  529. (when (memq delim '(?' ?/))
  530. (forward-char)
  531. (setq end (eshell-find-delimiter delim delim nil nil t)
  532. sep (buffer-substring-no-properties (point) end))
  533. (goto-char (1+ end)))
  534. `(lambda (lst)
  535. (mapcar
  536. (function
  537. (lambda (str)
  538. (split-string str ,sep))) lst))))
  539. (provide 'em-pred)
  540. ;; Local Variables:
  541. ;; generated-autoload-file: "esh-groups.el"
  542. ;; End:
  543. ;;; em-pred.el ends here