Warning, /sdk/kde-dev-scripts/kde-emacs/kde-emacs-compat.el is written in an unsupported language. File is not indexed.

0001 ;; kde-emacs-compat.el - contains compatibility functions
0002 ;;
0003 ;; Copyright (C)  2003  Zack Rusin <zack@kde.org>
0004 ;;                2003  KDE Developlment team
0005 ;;                2003  XEmacs developers
0006 ;;
0007 ;; This program is free software; you can redistribute it and/or
0008 ;; modify it under the terms of the GNU General Public License
0009 ;; as published by the Free Software Foundation; either version 2
0010 ;; of the License, or (at your option) any later version.
0011 ;;
0012 ;; This program is distributed in the hope that it will be useful,
0013 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 ;; GNU General Public License for more details.
0016 ;;
0017 ;; You should have received a copy of the GNU General Public License
0018 ;; along with this program; if not, write to the Free Software
0019 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0020 ;; 02110-1301, USA.
0021 
0022 (require 'kde-emacs-vars)
0023 
0024 ;;GNU/Emacs does not have this one
0025 (if (not (fboundp 'replace-in-string))
0026     (defun replace-in-string (str regexp newtext &optional literal)
0027       "Replace all matches in STR for REGEXP with NEWTEXT string,
0028  and returns the new string.
0029 Optional LITERAL non-nil means do a literal replacement.
0030 Otherwise treat `\\' in NEWTEXT as special:
0031   `\\&' in NEWTEXT means substitute original matched text.
0032   `\\N' means substitute what matched the Nth `\\(...\\)'.
0033        If Nth parens didn't match, substitute nothing.
0034   `\\\\' means insert one `\\'.
0035   `\\u' means upcase the next character.
0036   `\\l' means downcase the next character.
0037   `\\U' means begin upcasing all following characters.
0038   `\\L' means begin downcasing all following characters.
0039   `\\E' means terminate the effect of any `\\U' or `\\L'."
0040       (if (> (length str) 50)
0041           (with-temp-buffer
0042             (insert str)
0043             (goto-char 1)
0044             (while (re-search-forward regexp nil t)
0045               (replace-match newtext t literal))
0046             (buffer-string))
0047         (let ((start 0) newstr)
0048           (while (string-match regexp str start)
0049             (setq newstr (replace-match newtext t literal str)
0050                   start (+ (match-end 0) (- (length newstr) (length str)))
0051                   str newstr))
0052           str)))
0053   
0054   )
0055 
0056 (if (not (fboundp 'read-shell-command))
0057     (progn
0058       (defvar read-shell-command-map
0059         (let ((map (make-sparse-keymap 'read-shell-command-map)))
0060           (if (eq kde-emacs-type 'xemacs)
0061               (set-keymap-parents map (list minibuffer-local-map))
0062             (set-keymap-parent map minibuffer-local-map))
0063           (define-key map "\t" 'comint-dynamic-complete)
0064           (define-key map "\M-\t" 'comint-dynamic-complete)
0065           (define-key map "\M-?" 'comint-dynamic-list-completions)
0066           map)
0067         "Minibuffer keymap used by `shell-command' and related commands.")
0068       (defun read-shell-command (prompt &optional initial-input history default-value)
0069         "Just like read-string, but uses read-shell-command-map:
0070 \\{read-shell-command-map}"
0071         (let ((minibuffer-completion-table nil))
0072           (read-from-minibuffer prompt initial-input read-shell-command-map
0073                                 nil (or history 'shell-command-history)
0074                                 nil default-value)))
0075       ))
0076 
0077 (provide 'kde-emacs-compat)