all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* length of query-replace-history list
@ 2006-05-31 16:38 B. T. Raven
  2006-05-31 18:34 ` Kevin Rodgers
       [not found] ` <mailman.2489.1149100587.9609.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: B. T. Raven @ 2006-05-31 16:38 UTC (permalink / raw)


Is it possible to set the maximum length of this variable to 2? I want to
write the from and to strings either to an association list or to a buffer
with one dotted pair per line. Maybe this is equivalent to repeatedly
setqing it to nil. ??

Thanks,

Ed

--

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

* Re: length of query-replace-history list
  2006-05-31 16:38 length of query-replace-history list B. T. Raven
@ 2006-05-31 18:34 ` Kevin Rodgers
       [not found] ` <mailman.2489.1149100587.9609.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2006-05-31 18:34 UTC (permalink / raw)


B. T. Raven wrote:
> Is it possible to set the maximum length of this variable to 2? I want to
> write the from and to strings either to an association list or to a buffer
> with one dotted pair per line. Maybe this is equivalent to repeatedly
> setqing it to nil. ??

,----[ C-h v history-length RET ]
| history-length is a variable defined in `C source code'.
| Its value is 30
|
| Documentation:
| *Maximum length for history lists before truncation takes place.
| A number means that length; t means infinite.  Truncation takes place
| just after a new element is inserted.  Setting the history-length
| property of a history variable overrides this default.
|
| You can customize this variable.
|
| [back]
`----

So (put 'query-replace-history 'history-length 2)

-- 
Kevin

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

* Re: length of query-replace-history list
       [not found] ` <mailman.2489.1149100587.9609.help-gnu-emacs@gnu.org>
@ 2006-06-01 15:29   ` B. T. Raven
  2006-06-01 21:36     ` Kevin Rodgers
  0 siblings, 1 reply; 4+ messages in thread
From: B. T. Raven @ 2006-06-01 15:29 UTC (permalink / raw)



"Kevin Rodgers" <ihs_4664@yahoo.com> wrote in message
news:mailman.2489.1149100587.9609.help-gnu-emacs@gnu.org...
> B. T. Raven wrote:
> > Is it possible to set the maximum length of this variable to 2? I want
to
> > write the from and to strings either to an association list or to a
buffer
> > with one dotted pair per line. Maybe this is equivalent to repeatedly
> > setqing it to nil. ??
>
> ,----[ C-h v history-length RET ]
> | history-length is a variable defined in `C source code'.
> | Its value is 30
> |
> | Documentation:
> | *Maximum length for history lists before truncation takes place.
> | A number means that length; t means infinite.  Truncation takes place
> | just after a new element is inserted.  Setting the history-length
> | property of a history variable overrides this default.
> |
> | You can customize this variable.
> |
> | [back]
> `----
>
> So (put 'query-replace-history 'history-length 2)
>
> --
> Kevin
>
>
>

Thanks, Kevin. Now that I understand what's going on, it doesn't seem like
it's worth while just to save a few hundred bytes. I had an idea to save
the qrh into a saved association list, something like:

(setq sal (cons (cons  (cadr query-replace-history) (car
query-replace-history)) sal))

The idea is to re-load this later and run query replace in batch mode on
other files. I have no idea how to do this in detail but it seems possible
and it would be very useful to me. Maybe instead of setting it to 2, I'll
set it to t, and then then figure out how to manipulate the resulting flat
list of strings after an hours' long session of query-replacing.

Since for my needs this list (sal) of dotted pairs would be a few thousand
elements long, it is probably not the best data structure to use. Could
something along this line be done with a hash table?

Thanks again,

Ed.

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

* Re: length of query-replace-history list
  2006-06-01 15:29   ` B. T. Raven
@ 2006-06-01 21:36     ` Kevin Rodgers
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2006-06-01 21:36 UTC (permalink / raw)


B. T. Raven wrote:
> Thanks, Kevin. Now that I understand what's going on, it doesn't seem like
> it's worth while just to save a few hundred bytes. I had an idea to save
> the qrh into a saved association list, something like:
> 
> (setq sal (cons (cons  (cadr query-replace-history) (car
> query-replace-history)) sal))

You could use desktop-save-mode and add query-replace-history to
desktop-globals-to-save.

> The idea is to re-load this later and run query replace in batch mode on
> other files. I have no idea how to do this in detail but it seems possible
> and it would be very useful to me. Maybe instead of setting it to 2, I'll
> set it to t, and then then figure out how to manipulate the resulting flat
> list of strings after an hours' long session of query-replacing.

You could also set desktop-base-file-name to specify a file just for
this specific purpose, and save just the last elements of
query-replace-history.

,----[ C-h v desktop-save-hook RET ]
| desktop-save-hook is a variable defined in `desktop.el'.
| Its value is nil
|
| Documentation:
| Normal hook run before the desktop is saved in a desktop file.
| This is useful for truncating history lists, for example.
|
| You can customize this variable.
|
| [back]
`----

(setq desktop-base-file-name ".emacs.batch.desktop"
       desktop-globals-to-save 'query-replace-history)

(add-hook desktop-save-hook
	  (lambda ()
	    (when (cdr (cdr query-replace-history))
	      (setcdr (cdr query-replace-history) nil))))

> Since for my needs this list (sal) of dotted pairs would be a few thousand
> elements long, it is probably not the best data structure to use. Could
> something along this line be done with a hash table?

Do you want all of the history or not?  If you only want 2 elements as
you originally said, then don't bother saving and manipulating anything
else.  If you do want the whole history, a list of strings may be as
good as anything -- after all, how do you know which search and replace
strings to use?

Finally, note that you can set query-replace-from-history-variable
and query-replace-to-history-variable to different symbols, and save
them instead.

-- 
Kevin

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

end of thread, other threads:[~2006-06-01 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-31 16:38 length of query-replace-history list B. T. Raven
2006-05-31 18:34 ` Kevin Rodgers
     [not found] ` <mailman.2489.1149100587.9609.help-gnu-emacs@gnu.org>
2006-06-01 15:29   ` B. T. Raven
2006-06-01 21:36     ` Kevin Rodgers

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.