branch: master commit 2f888c50039edd5afcb189759fd2eb176367bd28 Author: Alexey Veretennikov <alexey.veretenni...@gmail.com> Commit: Alexey Veretennikov <alexey.veretenni...@gmail.com>
Added util file --- ztree-util.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/ztree-util.el b/ztree-util.el new file mode 100644 index 0000000..00690be --- /dev/null +++ b/ztree-util.el @@ -0,0 +1,54 @@ +;;; ztree-util.el --- Auxulary utilities for the ztree package + +;; Copyright (C) 2013 Alexey Veretennikov +;; +;; Author: Alexey Veretennikov <alexey dot veretennikov at gmail dot com> +;; Created: 2013-11-1l +;; Version: 1.0.0 +;; Keywords: files +;; URL: https://github.com/fourier/ztree +;; Compatibility: GNU Emacs GNU Emacs 24.x +;; +;; This file is NOT part of GNU Emacs. +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 2 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. +;; +;;; Commentary: + +(defun ztree-find (where which) + "find element of the list `where` matching predicate `which`" + (catch 'found + (dolist (elt where) + (when (funcall which elt) + (throw 'found elt))) + nil)) + +(defun ztree-filter (condp lst) + "Filter out elements of the list `lst` not satisfying predicate `condp`. +Taken from http://www.emacswiki.org/emacs/ElispCookbook#toc39" + (delq nil + (mapcar (lambda (x) (and (funcall condp x) x)) lst))) + + +(defun printable-string (string) + "Strip newline character from file names, like 'Icon\n'" + (replace-regexp-in-string "\n" "" string)) + +(defun file-short-name (file) + "Base file/directory name. Taken from + http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg01238.html" + (printable-string (file-name-nondirectory (directory-file-name file)))) + + +(provide 'ztree-util)