em-pred.el 19 KB

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