From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: mb-pos.el (was: Minibuffer default values list) Date: Sun, 25 Nov 2007 17:18:48 +0200 Organization: JURTA Message-ID: <87y7cmh026.fsf_-_@jurta.org> References: <87zlycuhrd.fsf@jurta.org> <87hckbecc0.fsf@jurta.org> <87prygxtot.fsf@jurta.org> <87hcjjkrgy.fsf@jurta.org> <87ir3u9r5s.fsf@jurta.org> <87myt3zk65.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1196004901 5718 80.91.229.12 (25 Nov 2007 15:35:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Nov 2007 15:35:01 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 25 16:35:08 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IwJVj-0000Pp-1b for ged-emacs-devel@m.gmane.org; Sun, 25 Nov 2007 16:35:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IwJVU-0004nv-7M for ged-emacs-devel@m.gmane.org; Sun, 25 Nov 2007 10:34:52 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IwJVP-0004mw-W7 for emacs-devel@gnu.org; Sun, 25 Nov 2007 10:34:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IwJVP-0004mc-Ks for emacs-devel@gnu.org; Sun, 25 Nov 2007 10:34:47 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IwJVP-0004mT-9G for emacs-devel@gnu.org; Sun, 25 Nov 2007 10:34:47 -0500 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IwJVJ-0007ZO-DO; Sun, 25 Nov 2007 10:34:41 -0500 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1IwJVE-000EXT-E3; Sun, 25 Nov 2007 17:34:38 +0200 In-Reply-To: (Richard Stallman's message of "Sat, 24 Nov 2007 22:43:13 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-Scanner-Signature: f43789f45b275c1a27cfade36eb2e696 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 1827 [Nov 24 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Method: none X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.7-5.2 (or MacOS X 10.2-10.4) (2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:84113 Archived-At: --=-=-= > + (run-hooks 'goto-history-element-pre-hook) > > How about running this hook only when moving into the "future"? > > Why preserve any ambient binding? I think it should bbe completely > superseded. > > For that reason, maybe it should be `goto-history-element-pre-function' > and its value should be just one function. > > A better name would be `goto-history-defaults-function'. The reason I added a new hook `goto-history-element-pre-hook' is to add later another symmetric hook `goto-history-element-post-hook' necessary for implementing another feature: with the recent improvements in the minibuffer functionality it became essential for the user to know the current minibuffer position in the history list or in the "future" values list. To indicate the current minibuffer position I've created a new file mb-pos.el attached below based in the existing file mb-depth.el with the very similar functionality. Since both files are very short, perhaps we should even rename mb-depth.el to mb-ind.el (minibuffer indications), and merge mb-pos.el into this common file. Index: lisp/simple.el =================================================================== RCS file: /sources/emacs/emacs/lisp/simple.el,v retrieving revision 1.889 diff -u -r1.889 simple.el --- lisp/simple.el 15 Nov 2007 16:42:43 -0000 1.889 +++ lisp/simple.el 25 Nov 2007 15:18:27 -0000 @@ -1302,6 +1302,7 @@ "Puts element of the minibuffer history in the minibuffer. The argument NABS specifies the absolute history position." (interactive "p") + (run-hooks 'goto-history-element-pre-hook) (let ((minimum (if minibuffer-default (- (if (listp minibuffer-default) (length minibuffer-default) @@ -1344,7 +1345,8 @@ (let ((print-level nil)) (prin1-to-string elt)) elt)) - (goto-char (or minibuffer-temporary-goal-position (point-max))))) + (goto-char (or minibuffer-temporary-goal-position (point-max))) + (run-hooks 'goto-history-element-post-hook))) (defun next-history-element (n) "Puts next element of the minibuffer history in the minibuffer. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=mb-pos.el Content-Transfer-Encoding: quoted-printable ;;; mb-pos.el --- Indicate minibuffer-history-position in prompt ;; ;; Copyright (C) 2007 Free Software Foundation, Inc. ;; ;; Author: Juri Linkov ;; Keywords: convenience ;; This file is part of GNU Emacs. ;; GNU Emacs 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 3, or (at your option) ;; any later version. ;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; ;; Defines the minor mode `minibuffer-history-position-indicate-mode'. ;; ;; When active, navigating in the minibuffer history with M-p or M-n keys ;; will show the current history position in the minibuffer prompt. ;;; Code: (defvar minibuffer-history-position-indicator-function nil "If non-nil, function to set up the minibuffer history position indicator. It is called with one argument, the minibuffer history position, and must return a string.") ;; An overlay covering the prompt. This is a buffer-local variable in ;; each affected minibuffer. ;; (defvar minibuffer-history-position-overlay) (make-variable-buffer-local 'minibuffer-history-position-overlay) ;; This function goes on goto-history-element-post-hook (defun minibuffer-history-position-setup () "Set up a minibuffer for `minibuffer-history-position-indicate-mode'. The prompt should already have been inserted." (unless (overlayp minibuffer-history-position-overlay) (setq minibuffer-history-position-overlay (make-overlay (point-min) (1+ (point-min))))) (overlay-put minibuffer-history-position-overlay 'before-string (if minibuffer-history-position-indicator-function (funcall minibuffer-history-position-indicator-function minibuffer-history-position) (propertize (format "%d:" minibuffer-history-position) 'face 'minibuffer-prompt))) (overlay-put minibuffer-history-position-overlay 'evaporate t)) ;;;###autoload (define-minor-mode minibuffer-history-position-indicate-mode "Toggle Minibuffer History Position Indication mode. When active, navigating in the minibuffer history with M-p or M-n keys will show the current history position in the minibuffer prompt. With prefix argument ARG, turn on if positive, otherwise off. Returns non-nil if the new state is enabled." :global t :group 'minibuffer (if minibuffer-history-position-indicate-mode (progn ;; Enable the mode (add-hook 'minibuffer-setup-hook 'minibuffer-history-position-setup) (add-hook 'goto-history-element-post-hook 'minibuffer-history-posit= ion-setup)) ;; Disable the mode (remove-hook 'minibuffer-setup-hook 'minibuffer-history-position-setup) (remove-hook 'goto-history-element-post-hook 'minibuffer-history-positi= on-setup))) (provide 'mb-pos) ;; arch-tag: 50224089-5bf5-46f8-803d-18f018c5eacf ;;; mb-pos.el ends here --=-=-= -- Juri Linkov http://www.jurta.org/emacs/ --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--