all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs22 large file y-or-n-p
@ 2006-06-13 23:19 Brendan Halpin
  2006-06-14  0:15 ` Pascal Bourguignon
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Brendan Halpin @ 2006-06-13 23:19 UTC (permalink / raw)


Emacs 22 has a check when visiting files for size, and a threshold
above which it queries the user whether s/he really wants to load
the file. Mostly this is a good idea, but I regularly want to load
my ~/RMAIL which gets ridiculously large.

Is there a lightweight way to avoid the check for RMAIL? I've
looked at the code (for find-file-noselect) and that permits
different size thresholds (and turning the check off altogether). 

Would defadvice around the rmail defun provide a handle? e.g.
temporarily raise the threshold variable's value to 100MB and
revert it afterwards?


Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-13 23:19 Emacs22 large file y-or-n-p Brendan Halpin
@ 2006-06-14  0:15 ` Pascal Bourguignon
  2006-06-14  8:20   ` Tim X
  2006-06-14  8:34   ` Brendan Halpin
  2006-06-14  8:16 ` Reiner Steib
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 12+ messages in thread
From: Pascal Bourguignon @ 2006-06-14  0:15 UTC (permalink / raw)


Brendan Halpin <brendan.halpin@ul.ie> writes:

> Emacs 22 has a check when visiting files for size, and a threshold
> above which it queries the user whether s/he really wants to load
> the file. Mostly this is a good idea, but I regularly want to load
> my ~/RMAIL which gets ridiculously large.
>
> Is there a lightweight way to avoid the check for RMAIL? I've
> looked at the code (for find-file-noselect) and that permits
> different size thresholds (and turning the check off altogether). 
>
> Would defadvice around the rmail defun provide a handle? e.g.
> temporarily raise the threshold variable's value to 100MB and
> revert it afterwards?

Really Brendan!  M-x apropos RET large.*file RET

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You never feed me.
Perhaps I'll sleep on your face.
That will sure show you.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-13 23:19 Emacs22 large file y-or-n-p Brendan Halpin
  2006-06-14  0:15 ` Pascal Bourguignon
@ 2006-06-14  8:16 ` Reiner Steib
  2006-06-14  9:03 ` Stein Arild Strømme
  2006-06-14  9:50 ` Mathias Dahl
  3 siblings, 0 replies; 12+ messages in thread
From: Reiner Steib @ 2006-06-14  8:16 UTC (permalink / raw)


On Wed, Jun 14 2006, Brendan Halpin wrote:

> Emacs 22 has a check when visiting files for size, and a threshold
> above which it queries the user whether s/he really wants to load
> the file. Mostly this is a good idea, but I regularly want to load
> my ~/RMAIL which gets ridiculously large.
>
> Is there a lightweight way to avoid the check for RMAIL? I've
> looked at the code (for find-file-noselect) and that permits
> different size thresholds (and turning the check off altogether). 

In Gnus, we have call `find-file-noselect' with the rawfile argument
when reading nnmbox and nnfolder files.  Maybe Rmail should do the
same if possible (I don't use Rmail).

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-14  0:15 ` Pascal Bourguignon
@ 2006-06-14  8:20   ` Tim X
  2006-06-14  8:34   ` Brendan Halpin
  1 sibling, 0 replies; 12+ messages in thread
From: Tim X @ 2006-06-14  8:20 UTC (permalink / raw)


Pascal Bourguignon <pjb@informatimago.com> writes:

> Brendan Halpin <brendan.halpin@ul.ie> writes:
>
>> Emacs 22 has a check when visiting files for size, and a threshold
>> above which it queries the user whether s/he really wants to load
>> the file. Mostly this is a good idea, but I regularly want to load
>> my ~/RMAIL which gets ridiculously large.
>>
>> Is there a lightweight way to avoid the check for RMAIL? I've
>> looked at the code (for find-file-noselect) and that permits
>> different size thresholds (and turning the check off altogether). 
>>
>> Would defadvice around the rmail defun provide a handle? e.g.
>> temporarily raise the threshold variable's value to 100MB and
>> revert it afterwards?
>
> Really Brendan!  M-x apropos RET large.*file RET
>

while Pascal's answer certainly is where you would start looking, it
doesn't address the issue of how to temporarily change the value while
reading mail and leaving it for everything else. 

I would certainly give defadvice a go - its the quickest and easiest
way to change behavior which cannot be achieved through customize in
the way you want. 

However, sometimes defadvice may not quite give you what you want. For
example, what would be the behavior if your running under X and open
mail in one frame and then got to do some other work in another frame.
It is possible, since the defadvice may not have completed, the
temporary change you enabled for mail is still set. This probably
wouldn't be an issue in this case, but I cannot say for certain, so
mention it anyway. 

It should also be noted there are situations in which modifying a
setting via a non-customize means, such as a setq, may not have the
consistent affect you expect. in fact, you do sometimes see
documentation which says, "Do not modify this variable by hand - use
customize" or something similar. 

However, as defadvice is so easy to do, I'd just do it in *scratch*
and see if it works.

Tim
-- 
tcross (at) rapttech dot com dot au

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-14  0:15 ` Pascal Bourguignon
  2006-06-14  8:20   ` Tim X
@ 2006-06-14  8:34   ` Brendan Halpin
  2006-06-14 15:58     ` Kevin Rodgers
       [not found]     ` <mailman.2887.1150300794.9609.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 12+ messages in thread
From: Brendan Halpin @ 2006-06-14  8:34 UTC (permalink / raw)


Pascal Bourguignon <pjb@informatimago.com> writes:

> Really Brendan!  M-x apropos RET large.*file RET

That doesn't tell me anything that wasn't clear from files.el --
I'm looking for a way to create a single exception, not turn it
off.

Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-13 23:19 Emacs22 large file y-or-n-p Brendan Halpin
  2006-06-14  0:15 ` Pascal Bourguignon
  2006-06-14  8:16 ` Reiner Steib
@ 2006-06-14  9:03 ` Stein Arild Strømme
  2006-06-14  9:20   ` Brendan Halpin
  2006-06-14  9:50 ` Mathias Dahl
  3 siblings, 1 reply; 12+ messages in thread
From: Stein Arild Strømme @ 2006-06-14  9:03 UTC (permalink / raw)


[Brendan Halpin]

| Emacs 22 has a check when visiting files for size, and a threshold
| above which it queries the user whether s/he really wants to load
| the file. Mostly this is a good idea, but I regularly want to load
| my ~/RMAIL which gets ridiculously large.

Why not move old mail elsewhere?  rmail has facilities for that.

SA
-- 
Stein Arild Strømme            +47 55584825, +47 95801887
Universitetet i Bergen                  Fax: +47 55589672     
Matematisk institutt               www.mi.uib.no/stromme/         
Johs Brunsg 12, N-5008 BERGEN           stromme@mi.uib.no

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-14  9:03 ` Stein Arild Strømme
@ 2006-06-14  9:20   ` Brendan Halpin
  0 siblings, 0 replies; 12+ messages in thread
From: Brendan Halpin @ 2006-06-14  9:20 UTC (permalink / raw)


stromme@mi.uib.no (Stein Arild Strømme) writes:

> Why not move old mail elsewhere?  rmail has facilities for that.

I do, but I like to keep at least a full month's mail in the
current folder. In fact, one of the main reasons I still use rmail
is that I prefer to use labels to organise mail, rather than
folders. 

My current RMAIL file holds 1.5 months of mail and is 35Mb. It'll
probably get twice as large before I archive again. That's not a
big problem for emacs, but it is the only large file I routinely
load. 

Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-13 23:19 Emacs22 large file y-or-n-p Brendan Halpin
                   ` (2 preceding siblings ...)
  2006-06-14  9:03 ` Stein Arild Strømme
@ 2006-06-14  9:50 ` Mathias Dahl
  2006-06-14 10:04   ` Brendan Halpin
  3 siblings, 1 reply; 12+ messages in thread
From: Mathias Dahl @ 2006-06-14  9:50 UTC (permalink / raw)


Brendan Halpin <brendan.halpin@ul.ie> writes:

> Is there a lightweight way to avoid the check for RMAIL? I've
> looked at the code (for find-file-noselect) and that permits
> different size thresholds (and turning the check off altogether). 
>
> Would defadvice around the rmail defun provide a handle? e.g.
> temporarily raise the threshold variable's value to 100MB and
> revert it afterwards?

If I had this problem I would have hacked rmail.el, doing the below,
or similar.

Changed this:

       (let ((enable-local-variables nil))
	 (find-file-noselect file-name))

to this:

       (let ((large-file-warning-threshold nil)
             (enable-local-variables nil))
	 (find-file-noselect file-name))

or maybe to this:

       (let ((large-file-warning-threshold 40000000)
             (enable-local-variables nil))
	 (find-file-noselect file-name))

Or, in this code in files.el:

	(when (and large-file-warning-threshold (nth 7 attributes)
		   ;; Don't ask again if we already have the file or
		   ;; if we're asked to be quiet.

;;;;;;;; NEW CHECK STARTS HERE

                   (not (string-match large-file-warning-exceptions filename))

;;;;;;;; NEW CHECK ENDS HERE

                   (not (or buf nowarn))
		   (> (nth 7 attributes) large-file-warning-threshold)
		   (not (y-or-n-p
			 (format "File %s is large (%dMB), really open? "
				 (file-name-nondirectory filename)
				   (/ (nth 7 attributes) 1048576)))))

;; New variable

(defvar large-file-warning-exceptions nil
 "Regexp matching files that wont get their size checked")

;; And in your .emacs

(setq large-file-warning-exceptions "my_rmail_file_regexp")

This is probably the best solution in that it is more general.

But I would not recommend changing Emacs "internal" lisp files in case
you are prepared to get into trouble when new versions come.

Or use the defadvice adviced (haha) by some people here.

/Mathias

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-14  9:50 ` Mathias Dahl
@ 2006-06-14 10:04   ` Brendan Halpin
  2006-06-14 10:37     ` Giorgos Keramidas
  0 siblings, 1 reply; 12+ messages in thread
From: Brendan Halpin @ 2006-06-14 10:04 UTC (permalink / raw)


Mathias Dahl <brakjoller@gmail.com> writes:

> Or, in this code in files.el:
>
> 	(when (and large-file-warning-threshold (nth 7 attributes)
> 		   ;; Don't ask again if we already have the file or
> 		   ;; if we're asked to be quiet.
>
> ;;;;;;;; NEW CHECK STARTS HERE
>
>                    (not (string-match large-file-warning-exceptions filename))
>
> ;;;;;;;; NEW CHECK ENDS HERE
>
>                    (not (or buf nowarn))
> 		   (> (nth 7 attributes) large-file-warning-threshold)
> 		   (not (y-or-n-p
> 			 (format "File %s is large (%dMB), really open? "
> 				 (file-name-nondirectory filename)
> 				   (/ (nth 7 attributes) 1048576)))))
>
> ;; New variable
>
> (defvar large-file-warning-exceptions nil
>  "Regexp matching files that wont get their size checked")
>
> ;; And in your .emacs
>
> (setq large-file-warning-exceptions "my_rmail_file_regexp")
>
> This is probably the best solution in that it is more general.

That is the best solution (or something very like it -- a list of
exceptions, perhaps).

Where should feature requests for Emacs22 be sent?

Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-14 10:04   ` Brendan Halpin
@ 2006-06-14 10:37     ` Giorgos Keramidas
  0 siblings, 0 replies; 12+ messages in thread
From: Giorgos Keramidas @ 2006-06-14 10:37 UTC (permalink / raw)


Brendan Halpin <brendan.halpin@ul.ie> wrote:
> Mathias Dahl <brakjoller@gmail.com> writes:
>> [sample code for a new large-file-warning-exceptions variable]
>>
>> (setq large-file-warning-exceptions "my_rmail_file_regexp")
>>
>> This is probably the best solution in that it is more general.
>
> That is the best solution (or something very like it -- a list of
> exceptions, perhaps).
>
> Where should feature requests for Emacs22 be sent?

AFAIK, <emacs-devel@gnu.org> is the right place for discussions about
new features.

- Giorgos

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
  2006-06-14  8:34   ` Brendan Halpin
@ 2006-06-14 15:58     ` Kevin Rodgers
       [not found]     ` <mailman.2887.1150300794.9609.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2006-06-14 15:58 UTC (permalink / raw)


Brendan Halpin wrote:
> Pascal Bourguignon <pjb@informatimago.com> writes:
> 
>> Really Brendan!  M-x apropos RET large.*file RET
> 
> That doesn't tell me anything that wasn't clear from files.el --
> I'm looking for a way to create a single exception, not turn it
> off.

Untested:

(defvar large-file-warning-threshold-exceptions nil
   "A list of regexps matching names of large files to be visited 
without query.
This temporarily overrides `large-file-warning-threshold'.")

(defadvice find-file-noselect (around
  			       large-file-warning-threshold-exceptions
			       activate)
   "Respect `large-file-warning-threshold-exceptions'."
   (let ((large-file-warning-threshold
	 (if (and large-file-warning-threshold-exceptions
		  (catch 'any
		    (mapc (lambda (regexp)
			    (when (string-match regexp (ad-get-arg 0))
			      (throw 'any t)))
			  large-file-warning-threshold-exceptions)
		    nil))
	     nil			; disabled
	   large-file-warning-threshold)))
     (ad-do-it)))

-- 
Kevin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Emacs22 large file y-or-n-p
       [not found]     ` <mailman.2887.1150300794.9609.help-gnu-emacs@gnu.org>
@ 2006-06-14 16:08       ` Brendan Halpin
  0 siblings, 0 replies; 12+ messages in thread
From: Brendan Halpin @ 2006-06-14 16:08 UTC (permalink / raw)


Kevin Rodgers <ihs_4664@yahoo.com> writes:

> Untested:
>
> (defvar large-file-warning-threshold-exceptions nil
>   "A list of regexps matching names of large files to be visited
> without query.
> This temporarily overrides `large-file-warning-threshold'.")
>
> (defadvice find-file-noselect (around
>  			       large-file-warning-threshold-exceptions
> 			       activate)
>   "Respect `large-file-warning-threshold-exceptions'."
>   (let ((large-file-warning-threshold
> 	 (if (and large-file-warning-threshold-exceptions
> 		  (catch 'any
> 		    (mapc (lambda (regexp)
> 			    (when (string-match regexp (ad-get-arg 0))
> 			      (throw 'any t)))
> 			  large-file-warning-threshold-exceptions)
> 		    nil))
> 	     nil			; disabled
> 	   large-file-warning-threshold)))
>     (ad-do-it)))


I like it. I hacked something defadvice-ing M-x rmail, but this is
more general. 

The only downside is that defadvice makes understanding program
behaviour more difficult. 

Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-06-14 16:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-13 23:19 Emacs22 large file y-or-n-p Brendan Halpin
2006-06-14  0:15 ` Pascal Bourguignon
2006-06-14  8:20   ` Tim X
2006-06-14  8:34   ` Brendan Halpin
2006-06-14 15:58     ` Kevin Rodgers
     [not found]     ` <mailman.2887.1150300794.9609.help-gnu-emacs@gnu.org>
2006-06-14 16:08       ` Brendan Halpin
2006-06-14  8:16 ` Reiner Steib
2006-06-14  9:03 ` Stein Arild Strømme
2006-06-14  9:20   ` Brendan Halpin
2006-06-14  9:50 ` Mathias Dahl
2006-06-14 10:04   ` Brendan Halpin
2006-06-14 10:37     ` Giorgos Keramidas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.