From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: Re: a quick way to switch orgmode notes between read-only/editing? Date: Fri, 18 Jul 2014 15:14:53 +0300 Message-ID: References: <87d2d49h63.fsf@gmail.com> <8761ivsgb2.fsf@ericabrahamsen.net> <8738dzt5bp.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b4148fe72858104fe76b4c1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X873w-0000Gv-Vh for emacs-orgmode@gnu.org; Fri, 18 Jul 2014 08:14:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X873v-00046F-Gf for emacs-orgmode@gnu.org; Fri, 18 Jul 2014 08:14:56 -0400 Received: from mail-oa0-x22a.google.com ([2607:f8b0:4003:c02::22a]:45998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X873v-00045y-Ad for emacs-orgmode@gnu.org; Fri, 18 Jul 2014 08:14:55 -0400 Received: by mail-oa0-f42.google.com with SMTP id n16so3040876oag.1 for ; Fri, 18 Jul 2014 05:14:54 -0700 (PDT) In-Reply-To: <8738dzt5bp.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: org mode --047d7b4148fe72858104fe76b4c1 Content-Type: text/plain; charset=UTF-8 Thx Thorsten i tried that but that dosent seem to work :) any way i can try to debug this (i apologize in advance for my zero lisp knowledge :) best Z On Fri, Jul 18, 2014 at 11:54 AM, Thorsten Jolitz wrote: > Xebar Saram writes: > > > Thx again all, really cool. > > > > one last question. anyone mind pasting code to revert an open buffer > > to read only when idle for lets say 5 minutes? > > you could try this (untested!): > > #+begin_src emacs-lisp > (defvar tj/last-buffer-tick nil) > (make-variable-buffer-local 'tj/last-buffer-tick) > > (add-hook 'org-mode-hook > (lambda () > (setq tj/last-buffer-tick (buffer-modified-tick)))) > > (defun tj/new-buffer-ticks-p () > (let ((curr-tick (buffer-modified-tick)) > (last-tick tj/last-buffer-tick)) > (setq tj/last-buffer-tick curr-tick) > (< last-tick curr-tick))) > > (defun tj/reset-view-mode () > (run-with-timer (* 5 60) (* 5 60) > (lambda () > (when (tj/new-buffer-ticks-p) > (view-mode t))))) > #+end_src > > > > On Fri, Jul 18, 2014 at 2:42 AM, Eric Abrahamsen > > wrote: > > > > Xebar Saram writes: > > > > > Thanks guys. really appreciate all your help > > > > > > im now using view-mode with hooks as suggested. btw whats the > > > advantages of viewer-mode over read-only-mode > > > > > > Mostly that you get more convenient navigation commands. Scrolling > > and > > searching etc don't require control modifiers, and it becomes a > > bit > > easier to move around files. > > > > > > > > > best > > > > > > Z > > > > > > > > > On Thu, Jul 17, 2014 at 5:46 PM, Jorge A. Alfaro-Murillo < > > > jorge.a.alfaro@gmail.com> wrote: > > > > > > Xebar Saram writes: > > > > > > > i keep once and a while screwing up my notes with unintended > > > editing > > > > (erroneous key presses etc) and was wondering if any one knew > > > of a way > > > > to to switch orgmode notes between read-only/editing? > > > > > > Hi Xebar. Use C-x C-q. This works for every file, I use it in > > > particular > > > for notes that I do not want to edit. > > > > > > It runs the command read-only-mode which changes whether the > > > current > > > buffer is read-only. Actually the command switches the local > > > variable > > > buffer-read-only, so you can use that variable as local for > > every > > > file > > > that you do not want to edit by default. At the end of those > > > files add: > > > > > > #+BEGIN_EXAMPLE > > > %%% Local Variables: > > > %%% buffer-read-only: t > > > %%% End: > > > #+END_EXAMPLE > > > > > > And every time that you want to edit them just do C-x C-q > > > > > > Best, > > > > > > Jorge. > > > > > > > > > > > > > > > > > > -- > cheers, > Thorsten > > > --047d7b4148fe72858104fe76b4c1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thx Thorsten

i tried that but that dose= nt seem to work :) any way i can try to debug this (i apologize in advance = for my zero lisp knowledge :)

best

Z


On Fri, Jul 18, 2014 at 11:54 AM, Thorsten Jolitz <tjolitz@gmai= l.com> wrote:
Xebar Saram <zeltakc@gmail.com> writes:

> Thx again all, really cool.
>
> one last question. anyone mind pasting code to revert an open buffer > to read only when idle for lets say 5 minutes?

you could try this (untested!):

#+begin_src emacs-lisp
(defvar tj/last-buffer-tick nil)
(make-variable-buffer-local 'tj/last-buffer-tick)

(add-hook 'org-mode-hook
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda ()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq tj/last-buffer-tick (buffer= -modified-tick))))

(defun tj/new-buffer-ticks-p ()
=C2=A0 (let ((curr-tick (buffer-modified-tick))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (last-tick tj/last-buffer-tick))
=C2=A0 =C2=A0 (setq tj/last-buffer-tick curr-tick)
=C2=A0 =C2=A0 (< last-tick curr-tick)))

(defun tj/reset-view-mode ()
=C2=A0 (run-with-timer (* 5 60) (* 5 60)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda () =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when= (tj/new-buffer-ticks-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (view-mode t)))))
#+end_src


> On Fri, Jul 18, 2014 at 2:42 AM, Eric Abrahamsen
> <eric@ericabrahamsen.net= > wrote:
>
> =C2=A0 =C2=A0 Xebar Saram <zel= takc@gmail.com> writes:
>
> =C2=A0 =C2=A0 > Thanks guys. really appreciate all your help
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > im now using view-mode with hooks as suggested. btw= whats the
> =C2=A0 =C2=A0 > advantages of viewer-mode over read-only-mode
>
>
> =C2=A0 =C2=A0 Mostly that you get more convenient navigation commands.= Scrolling
> =C2=A0 =C2=A0 and
> =C2=A0 =C2=A0 searching etc don't require control modifiers, and i= t becomes a
> =C2=A0 =C2=A0 bit
> =C2=A0 =C2=A0 easier to move around files.
>
>
>
> =C2=A0 =C2=A0 > best
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > Z
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > On Thu, Jul 17, 2014 at 5:46 PM, Jorge A. Alfaro-Mu= rillo <
> =C2=A0 =C2=A0 > jorge.a= .alfaro@gmail.com> wrote:
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > Xebar Saram <zeltakc@gmail.com> writes:
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > > i keep once and a while screwing up my notes w= ith unintended
> =C2=A0 =C2=A0 > editing
> =C2=A0 =C2=A0 > > (erroneous key presses etc) and was wondering = if any one knew
> =C2=A0 =C2=A0 > of a way
> =C2=A0 =C2=A0 > > to to switch orgmode notes between read-only/e= diting?
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > Hi Xebar. Use C-x C-q. This works for every file, I= use it in
> =C2=A0 =C2=A0 > particular
> =C2=A0 =C2=A0 > for notes that I do not want to edit.
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > It runs the command read-only-mode which changes wh= ether the
> =C2=A0 =C2=A0 > current
> =C2=A0 =C2=A0 > buffer is read-only. Actually the command switches = the local
> =C2=A0 =C2=A0 > variable
> =C2=A0 =C2=A0 > buffer-read-only, so you can use that variable as l= ocal for
> =C2=A0 =C2=A0 every
> =C2=A0 =C2=A0 > file
> =C2=A0 =C2=A0 > that you do not want to edit by default. At the end= of those
> =C2=A0 =C2=A0 > files add:
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > #+BEGIN_EXAMPLE
> =C2=A0 =C2=A0 > %%% Local Variables:
> =C2=A0 =C2=A0 > %%% buffer-read-only: t
> =C2=A0 =C2=A0 > %%% End:
> =C2=A0 =C2=A0 > #+END_EXAMPLE
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > And every time that you want to edit them just do C= -x C-q
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > Best,
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > Jorge.
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 >
>
>
>
>
>

--
cheers,
Thorsten



--047d7b4148fe72858104fe76b4c1--