messages buffer history

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

messages buffer history

drain
How would I set the messages buffer to record the history of every folder I
have gone to in my current session?
Reply | Threaded
Open this post in threaded view
|

RE: messages buffer history

Drew Adams
> How would I set the messages buffer to record the history of
> every folder I have gone to in my current session?

Gone to how?

Maybe option `find-file-hook' or `dired-after-readin-hook' will help you.

(But why would you want to drown that history in a sea of other, unrelated
messages?  If you want a history of accessed folders, why not put that in a
separate buffer?)


Reply | Threaded
Open this post in threaded view
|

RE: messages buffer history

drain
> Gone to how?

"Accessed folders", which includes:

(1) M-x find-file RET usr/include RET
(2) M-x find-file RET ~/study/literature.org RET

> If you want a history of accessed folders, why not put that in a
>separate buffer?

Good idea. After (1) and (2), the separate buffer would read:

/usr/include
~/study
Reply | Threaded
Open this post in threaded view
|

Re: messages buffer history

Le Wang
On Fri, Jan 11, 2013 at 10:15 AM, drain <[hidden email]> wrote:

> (1) M-x find-file RET usr/include RET
> (2) M-x find-file RET ~/study/literature.org RET
>
>> If you want a history of accessed folders, why not put that in a
>>separate buffer?
>
> Good idea. After (1) and (2), the separate buffer would read:
>
> /usr/include
> ~/study

Emacs already tracks this information, no need to add hooks.

(defun get-session-dirs ()
  "return list of directories visited in session"
  (delete-dups
   (mapcar (lambda (f)
             (file-name-directory f))
           file-name-history)))

List of directory returned is in reverse chronological order.

--
Le

Reply | Threaded
Open this post in threaded view
|

Re: messages buffer history

drain
> List of directory returned is in reverse chronological order.

How would I insert the returned list into a buffer?
Reply | Threaded
Open this post in threaded view
|

Re: messages buffer history

Le Wang
On Fri, Jan 11, 2013 at 4:44 PM, drain <[hidden email]> wrote:
>> List of directory returned is in reverse chronological order.
>
> How would I insert the returned list into a buffer?

I think it's time to crack open that Elisp tutorial you're talking about:

(defun session-dirs ()
  "return list of directories visited in session"
  (delete-dups
   (mapcar (lambda (f)
             (file-name-directory f))
           file-name-history)))

(defun display-session-dirs ()
  "show list of session dirs in a buffer"
  (interactive)
  (pop-to-buffer (get-buffer-create "*session dirs*"))
  (erase-buffer)
  (insert (mapconcat 'identity (session-dirs) "\n")))


--
Le

Reply | Threaded
Open this post in threaded view
|

RE: messages buffer history

Drew Adams
In reply to this post by drain
> > Emacs already tracks this information, no need to add hooks.
> > List of directory returned is in reverse chronological order.
>
> How would I insert the returned list into a buffer?

And that list is only a snapshot taken at one moment.

I think the OP wanted a log, with the log being updated each time a dir is
accessed, so that it always accurately reflects the access history.

Hence the use of a hook.  That's what hooks are for.

You can use another kind of procedural attachment, or create another kind of
trigger, or even use a timer (modulo some delay in reflection).  

But some such mechanism is called for if you want to attach/couple an access
event to log output.


Reply | Threaded
Open this post in threaded view
|

RE: messages buffer history

drain
> I think the OP wanted a log, with the log being updated each time a dir
> is accessed, so that it always accurately reflects the access history.

That is precisely what I wanted, but Le Wang's interpretation ended up
being tidier than what I had in mind.

> I think it's time to crack open that Elisp tutorial you're talking about

Indeed. Left off at car cdr & cons...