From b11a5ce0763e16726c14b849cc94b6a392b30eb8 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Mon, 6 Jun 2005 07:30:02 +0000 Subject: [PATCH] (filename-special-filter-1): New macro defined for filename-special-filter to use aref instead of sref for the recent Emacsen. (filename-special-filter): Use it. --- ChangeLog | 7 +++++++ filename.el | 53 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 662525d..68e2cb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-06-06 Katsumi Yamaoka + + * filename.el (filename-special-filter-1): New macro defined for + filename-special-filter to use aref instead of sref for the recent + Emacsen. + (filename-special-filter): Use it. + 2005-06-05 Tatsuya Kinoshita * poe-xemacs.el: Load `timer' even if `timer-funcs' exists. diff --git a/filename.el b/filename.el index e04337a..98b8786 100644 --- a/filename.el +++ b/filename.el @@ -91,26 +91,41 @@ Moreover, if you want to convert Japanese filename to roman string by kakasi, (let ((code (char-int character))) (or (< code 32)(= code 127)))) +(eval-when-compile + (defmacro filename-special-filter-1 (string) + (let (sref inc-i) + (if (or (not (fboundp 'sref)) + (>= emacs-major-version 21) + (and (= emacs-major-version 20) + (>= emacs-minor-version 3))) + (setq sref 'aref + inc-i '(1+ i)) + (setq sref 'aref + inc-i '(+ i (char-length chr)))) + (` (let* ((string (, string)) + (len (length string)) + (b 0)(i 0) + (dest "")) + (while (< i len) + (let ((chr ((, sref) string i)) + (lst filename-replacement-alist) + ret) + (while (and lst (not ret)) + (if (if (functionp (car (car lst))) + (setq ret (funcall (car (car lst)) chr)) + (setq ret (memq chr (car (car lst))))) + t ; quit this loop. + (setq lst (cdr lst)))) + (if ret + (setq dest (concat dest (substring string b i) + (cdr (car lst))) + i (, inc-i) + b i) + (setq i (, inc-i))))) + (concat dest (substring string b))))))) + (defun filename-special-filter (string) - (let ((len (length string)) - (b 0)(i 0) - (dest "")) - (while (< i len) - (let ((chr (sref string i)) - (lst filename-replacement-alist) - ret) - (while (and lst (not ret)) - (if (if (functionp (car (car lst))) - (setq ret (funcall (car (car lst)) chr)) - (setq ret (memq chr (car (car lst))))) - t ; quit this loop. - (setq lst (cdr lst)))) - (if ret - (setq dest (concat dest (substring string b i)(cdr (car lst))) - i (+ i (char-length chr)) - b i) - (setq i (+ i (char-length chr)))))) - (concat dest (substring string b)))) + (filename-special-filter-1 string)) (defun filename-eliminate-top-low-lines (string) (if (string-match "^_+" string) -- 1.7.10.4