From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#17831: 24.4.50; bad default value for `Man-width' Date: Mon, 30 Jun 2014 02:42:28 +0300 Organization: JURTA Message-ID: <87zjgv5lln.fsf@mail.jurta.org> References: <87tx7buryg.fsf@mail.jurta.org> <53A92532.9040901@gmx.at> <83zjh2qpia.fsf@gnu.org> <83mwd2qji7.fsf@gnu.org> <83ha3aqdh5.fsf@gnu.org> <87tx79es0g.fsf@mail.jurta.org> <87y4wj9pzs.fsf@mail.jurta.org> <8761jlua54.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1404087764 10459 80.91.229.3 (30 Jun 2014 00:22:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Jun 2014 00:22:44 +0000 (UTC) Cc: 17831@debbugs.gnu.org, sdl.web@gmail.com To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 30 02:22:37 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X1PMf-00007S-LW for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Jun 2014 02:22:33 +0200 Original-Received: from localhost ([::1]:59782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1PMf-0003pp-54 for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Jun 2014 20:22:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1PMR-0003f2-Ul for bug-gnu-emacs@gnu.org; Sun, 29 Jun 2014 20:22:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1PMB-0006rw-Cz for bug-gnu-emacs@gnu.org; Sun, 29 Jun 2014 20:22:19 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1PMB-0006rr-9Y for bug-gnu-emacs@gnu.org; Sun, 29 Jun 2014 20:22:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X1PMA-0000VY-Uq for bug-gnu-emacs@gnu.org; Sun, 29 Jun 2014 20:22:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Jun 2014 00:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17831 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17831-submit@debbugs.gnu.org id=B17831.14040876971886 (code B ref 17831); Mon, 30 Jun 2014 00:22:02 +0000 Original-Received: (at 17831) by debbugs.gnu.org; 30 Jun 2014 00:21:37 +0000 Original-Received: from localhost ([127.0.0.1]:37215 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X1PLk-0000UJ-T1 for submit@debbugs.gnu.org; Sun, 29 Jun 2014 20:21:37 -0400 Original-Received: from alc-vshost7.dreamhost.com ([69.163.216.107]:46187 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X1PLh-0000UA-Hk for 17831@debbugs.gnu.org; Sun, 29 Jun 2014 20:21:34 -0400 Original-Received: from localhost.jurta.org (ps18281.dreamhostps.com [69.163.222.226]) by ps18281.dreamhostps.com (Postfix) with ESMTP id A6604348328E00; Sun, 29 Jun 2014 17:21:30 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 27 Jun 2014 21:30:50 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:90989 Archived-At: >> But still the users need an indication that the formatting >> is not finished. grep/compilation and vc display a string >> like "waiting..." or "compiling..." in the mode-line, so >> man.el could display in the mode-line "formatting..." > > Sound fine, After testing I see no problems with this patch: === modified file 'lisp/man.el' --- lisp/man.el 2014-05-09 07:02:00 +0000 +++ lisp/man.el 2014-06-29 23:37:38 +0000 @@ -1056,21 +1056,28 @@ (defun Man-getpage-in-background (topic) (require 'env) (message "Invoking %s %s in the background" manual-program man-args) (setq buffer (generate-new-buffer bufname)) + (Man-notify-when-ready buffer) (with-current-buffer buffer (setq buffer-undo-list t) (setq Man-original-frame (selected-frame)) - (setq Man-arguments man-args)) + (setq Man-arguments man-args) + (Man-mode) + (setq mode-line-process + (concat " " (propertize "[formatting...]" + 'face 'mode-line-emphasis)))) (Man-start-calling (if (fboundp 'start-process) - (set-process-sentinel - (start-process manual-program buffer + (let ((proc (start-process + manual-program buffer (if (memq system-type '(cygwin windows-nt)) shell-file-name "sh") shell-command-switch - (format (Man-build-man-command) man-args)) - 'Man-bgproc-sentinel) - (let ((exit-status + (format (Man-build-man-command) man-args)))) + (set-process-sentinel proc 'Man-bgproc-sentinel) + (set-process-filter proc 'Man-bgproc-filter)) + (let* ((inhibit-read-only t) + (exit-status (call-process shell-file-name nil (list buffer nil) nil shell-command-switch (format (Man-build-man-command) man-args))) @@ -1082,6 +1089,10 @@ (defun Man-getpage-in-background (topic) (format "exited abnormally with code %d" exit-status))) (setq msg exit-status)) + (with-current-buffer buffer + (if Man-fontify-manpage-flag + (Man-fontify-manpage) + (Man-cleanup-manpage))) (Man-bgproc-sentinel bufname msg))))) buffer)) @@ -1168,7 +1179,6 @@ (defun Man-fontify-manpage () "Convert overstriking and underlining to the correct fonts. Same for the ANSI bold and normal escape sequences." (interactive) - (message "Please wait: formatting the %s man page..." Man-arguments) (goto-char (point-min)) ;; Fontify ANSI escapes. (let ((ansi-color-apply-face-function @@ -1183,7 +1193,7 @@ (defun Man-fontify-manpage () ;; Multibyte characters exist. (progn (goto-char (point-min)) - (while (search-forward "__\b\b" nil t) + (while (and (search-forward "__\b\b" nil t) (not (eobp))) (backward-delete-char 4) (put-text-property (point) (1+ (point)) 'face 'Man-underline)) (goto-char (point-min)) @@ -1191,7 +1201,7 @@ (defun Man-fontify-manpage () (backward-delete-char 4) (put-text-property (1- (point)) (point) 'face 'Man-underline)))) (goto-char (point-min)) - (while (search-forward "_\b" nil t) + (while (and (search-forward "_\b" nil t) (not (eobp))) (backward-delete-char 2) (put-text-property (point) (1+ (point)) 'face 'Man-underline)) (goto-char (point-min)) @@ -1223,8 +1233,7 @@ (defun Man-fontify-manpage () (while (re-search-forward Man-heading-regexp nil t) (put-text-property (match-beginning 0) (match-end 0) - 'face 'Man-overstrike))) - (message "%s man page formatted" (Man-page-from-arguments Man-arguments))) + 'face 'Man-overstrike)))) (defun Man-highlight-references (&optional xref-man-type) "Highlight the references on mouse-over. @@ -1286,8 +1295,6 @@ (defun Man-cleanup-manpage (&optional in but when called interactively, do those jobs even if the sed script would have done them." (interactive "p") - (message "Please wait: cleaning up the %s man page..." - Man-arguments) (if (or interactive (not Man-sed-script)) (progn (goto-char (point-min)) @@ -1309,8 +1316,36 @@ (defun Man-cleanup-manpage (&optional in ;; their preceding chars (but don't put Man-overstrike). (Bug#5566) (goto-char (point-min)) (while (re-search-forward ".\b" nil t) (backward-delete-char 2)) - (Man-softhyphen-to-minus) - (message "%s man page cleaned up" Man-arguments)) + (Man-softhyphen-to-minus)) + +(defun Man-bgproc-filter (process string) + "Manpage background process filter. +When manpage command is run asynchronously, PROCESS is the process +object for the manpage command; when manpage command is run +synchronously, PROCESS is the name of the buffer where the manpage +command is run. Second argument STRING is the entire string of output." + (save-excursion + (let ((Man-buffer (process-buffer process))) + (if (null (buffer-name Man-buffer)) ;; deleted buffer + (set-process-buffer process nil) + + (with-current-buffer Man-buffer + (let ((inhibit-read-only t) + (beg (marker-position (process-mark process)))) + (save-excursion + (goto-char beg) + (insert string) + (save-restriction + (narrow-to-region + (save-excursion + (goto-char beg) + (line-beginning-position)) + (point)) + (if Man-fontify-manpage-flag + (Man-fontify-manpage) + (Man-cleanup-manpage))) + (set-marker (process-mark process) (point-max))))))))) (defun Man-bgproc-sentinel (process msg) "Manpage background process sentinel. @@ -1329,6 +1364,7 @@ (defun Man-bgproc-sentinel (process msg) (set-process-buffer process nil)) (with-current-buffer Man-buffer + (save-excursion (let ((case-fold-search nil)) (goto-char (point-min)) (cond ((or (looking-at "No \\(manual \\)*entry for") @@ -1364,28 +1400,34 @@ (defun Man-bgproc-sentinel (process msg) (insert (format "\nprocess %s" msg)))) )) (if delete-buff - (kill-buffer Man-buffer) - (if Man-fontify-manpage-flag - (Man-fontify-manpage) - (Man-cleanup-manpage)) + (if (get-buffer-window Man-buffer) + (quit-window t (get-buffer-window Man-buffer)) + (kill-buffer Man-buffer)) (run-hooks 'Man-cooked-hook) - (Man-mode) + + (Man-build-page-list) + (Man-strip-page-headers) + (Man-unindent) + (Man-goto-page 1 t) (if (not Man-page-list) (let ((args Man-arguments)) - (kill-buffer (current-buffer)) - (user-error "Can't find the %s manpage" + (if (get-buffer-window (current-buffer)) + (quit-window t (get-buffer-window (current-buffer))) + (kill-buffer (current-buffer))) + (message "Can't find the %s manpage" (Man-page-from-arguments args))) - (set-buffer-modified-p nil)))) - ;; Restore case-fold-search before calling - ;; Man-notify-when-ready because it may switch buffers. - (if (not delete-buff) - (Man-notify-when-ready Man-buffer)) + (if Man-fontify-manpage-flag + (message "%s man page formatted" (Man-page-from-arguments Man-arguments)) + (message "%s man page cleaned up" Man-arguments)) + (unless (and (processp process) (not (eq (process-status process) 'exit))) + (setq mode-line-process nil)) + (set-buffer-modified-p nil))))) (if err-mess - (error "%s" err-mess)) + (message "%s" err-mess)) )))) (defun Man-page-from-arguments (args) @@ -1458,11 +1500,7 @@ (define-derived-mode Man-mode fundamenta (set (make-local-variable 'outline-regexp) Man-heading-regexp) (set (make-local-variable 'outline-level) (lambda () 1)) (set (make-local-variable 'bookmark-make-record-function) - 'Man-bookmark-make-record) - (Man-build-page-list) - (Man-strip-page-headers) - (Man-unindent) - (Man-goto-page 1 t)) + 'Man-bookmark-make-record)) (defsubst Man-build-section-alist () "Build the list of manpage sections."