unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ken Manheimer" <ken.manheimer@gmail.com>
Subject: Re: allout encryption and non-ascii characters
Date: Mon, 6 Nov 2006 10:56:18 -0500	[thread overview]
Message-ID: <2cd46e7f0611060756k5f8caa92ocde9a2d24f907a8d@mail.gmail.com> (raw)
In-Reply-To: <2cd46e7f0611041128k57da936vda14f79f35259d58@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3566 bytes --]

though i haven't heard that anyone else has tested it, i would hate
for this allout patch to miss the release, and am confident enough
about its merits to ask that it be applied.

the crucial thing the patch does is enable topic encryption of
non-ascii encodings.  the encoding fix is only a few lines, but the
patch also eliminates a tradeoff in the last fix i submitted,
clarifies a variable name and some docstrings in the process, and
rectifies some assorted boundary-condition behaviors, as well.
-- 
ken
ken.manheimer@gmail.com
http://myriadicity.net

2006-11-05  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el (allout-doublecheck-at-and-shallower): Clarify
	docstring.
	(allout-inhibit-aberrance-doublecheck): Rename from
	allout-during-yank-processing.
	(allout-do-doublecheck): Track allout-inhibit-aberrance-doublecheck
	name change.
	(allout-ascend): Provide for unusual case where some topic after
	the first in file is at lower depth than the first.
	(allout-shift-in): Ensure the offspring of the new containing
	topic are exposed.
	(allout-encrypt-string): Preserve the coding-system of the text,
	according to that of the containing buffer.



On 11/4/06, Ken Manheimer <ken.manheimer@gmail.com> wrote:
> i have had some success with getting allout topic encryption to
> encrypt text so that characters in an alternate coding set are
> preserved.  i am looking for people to test it - i am so unfamiliar
> with coding sets in general that i don't really know how to be sure it
> works generally!  (i am excited, though, that i was able to round-trip
> some text with an elaborate <'> apostrophe that isn't preserved in the
> ascii character set, but is preserved in iso-2022-7bit.)
>
> i'm attaching a full copy of the revised allout.el for testing - make
> sure you're not getting byte code from an old version when giving it a
> go.  and when you do test it, be sure that the file you're working
> with has a coding set which preserves the characters on rereading -
> the encryption depends on the buffer being in the right coding set.
>
> let me know whether or not it works for you, and if possible, the
> coding set of the trial ('Esc-x buffer-file-coding-set' will tell
> you).  if i get good confirmation that this works, i'll submit a
> proper patch.
>
> thanks!
>
> On 11/1/06, Ken Manheimer <ken.manheimer@gmail.com> wrote:
> > allout's use of pgg for encryption doesn't provide for non-ascii text,
> > and encoding is a realm where i seem to have less than zero
> > cluefulness.  can anyone help me solve the problem posed below?
> >
> > ken
> >
> > On 11/1/06, an david smith wrote:
> >
> > > Hi Ken,
> > >
> > > I've been an allout user for a very long time. It's wonderful
> > > software. Thank you.
> > >
> > > Today I thought I'd try out the encryption support as I finally
> > > have a need for it but it doesn't properly handle non-ascii
> > > characters. pgg-output-buffer is created inside of pgg-gpg with
> > > mode of raw-text or binary and that is never converted back
> > > into the charset of the original cleartext. I do a lot of work
> > > in Japanese and so this is critical.
> > >
> > > I look at how gnus uses pgg and its charset handling but even
> > > in edebug I couldn't quite see how it was doing it correctly
> > > compared to how allout's method.
> > >
> > > If you have any insight I would really appreciate it. I will
> > > try to debug this in my own time but as you are the
> > > maintainer/author of the software involved, I hope you can at
> > > least nudge in me the right direction towards a fix.

[-- Attachment #2: ChangeLog-entry.txt --]
[-- Type: text/plain, Size: 496 bytes --]

2006-11-05  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el (allout-doublecheck-at-and-shallower): Clarify
	docstring.
	(allout-inhibit-aberrance-doublecheck): Rename from
	allout-during-yank-processing.
	(allout-do-doublecheck): Track allout-inhibit-aberrance-doublecheck
	name change.
	(allout-ascend): Provide for unusual case where some topic after
	the first in file is at lower depth than the first.
	(allout-shift-in): Ensure the offspring of the new containing
	topic are exposed.

[-- Attachment #3: allout-patch.txt --]
[-- Type: text/plain, Size: 7089 bytes --]

--- allout.el	05 Nov 2006 10:10:31 -0500	1.87
+++ allout.el	06 Nov 2006 10:46:13 -0500	
@@ -895,14 +895,9 @@
   "Validate apparent topics of this depth and shallower as being non-aberrant.
 
 Verified with `allout-aberrant-container-p'.  This check's usefulness is
-limited to shallow prospects, because the determination of aberrance
-depends on the mistaken item being followed by a legitimate item of
-excessively greater depth.
-
-A level of 2 is safest, so that yanks, which must ignore
-aberrance while rectifying the yanked text to their new location,
-is least likely to be fooled by aberrant topics in the yanked
-text.")
+limited to shallow depths, because the determination of aberrance
+is according to the mistaken item being followed by a legitimate item of
+excessively greater depth.")
 ;;;_   X allout-reset-header-lead (header-lead)
 (defun allout-reset-header-lead (header-lead)
   "*Reset the leading string used to identify topic headers."
@@ -1511,13 +1506,18 @@
     (goto-char (cadr allout-after-save-decrypt))
     (setq allout-after-save-decrypt nil))
   )
-;;;_   = allout-during-yank-processing nil
-;; XXX allout yanks adjust the level of the topic being pasted to that of
-;; their target location.  aberrance must be inhibited to allow that
-;; reconciliation.  (this means that actually aberrant topics won't be
-;; treated specially while being pasted.)
-(defvar allout-during-yank-processing nil
-  "Internal state, inhibits aberrance doublecheck while adjusting yanks.")
+;;;_   = allout-inhibit-aberrance-doublecheck nil
+;; In some exceptional moments, disparate topic depths need to be allowed
+;; momentarily, eg when one topic is being yanked into another and they're
+;; about to be reconciled.  let-binding allout-inhibit-aberrance-doublecheck
+;; prevents the aberrance doublecheck to allow, eg, the reconciliation
+;; processing to happen in the presence of such discrepancies.  It should
+;; almost never be needed, however.
+(defvar allout-inhibit-aberrance-doublecheck nil
+  "Internal state, for momentarily inhibits aberrance doublecheck.
+
+This should only be momentarily let-bound non-nil, not set
+non-nil in a lasting way.")
 
 ;;;_ #2 Mode activation
 ;;;_  = allout-explicitly-deactivated
@@ -2212,7 +2212,7 @@
   (and
    ;; presume integrity of outline and yanked content during yank - necessary,
    ;; to allow for level disparity of yank location and yanked text:
-   (not allout-during-yank-processing)
+   (not allout-inhibit-aberrance-doublecheck)
    ;; allout-doublecheck-at-and-shallower is ceiling for doublecheck:
    (<= allout-recent-depth allout-doublecheck-at-and-shallower)))
 ;;;_     > allout-aberrant-container-p ()
@@ -2891,7 +2891,15 @@
   "Ascend one level, returning t if successful, nil if not."
   (prog1
       (if (allout-beginning-of-level)
-          (allout-previous-heading))
+          (let ((bolevel (point))
+                (bolevel-depth allout-recent-depth))
+            (allout-previous-heading)
+            (if (< allout-recent-depth bolevel-depth)
+                allout-recent-depth
+              ;; some topic after file's first is at lower depth than first:
+              (goto-char bolevel)
+              (allout-depth)
+              nil)))
     (if (interactive-p) (allout-end-of-prefix))))
 ;;;_   > allout-descend-to-depth (depth)
 (defun allout-descend-to-depth (depth)
@@ -3502,8 +3510,6 @@
 
 If OFFER-RECENT-BULLET is true, offer to use the bullet of the prior sibling.
 
-Runs
-
 Nuances:
 
 - Creation of new topics is with respect to the visible topic
@@ -4145,7 +4151,10 @@
                      (> (1+ current-depth)
                         (1+ predecessor-depth)))
                 (error (concat "Disallowed shift deeper than"
-                               " containing topic's children."))))))
+                               " containing topic's children."))
+              (allout-back-to-current-heading)
+              (if (< allout-recent-depth (1+ current-depth))
+                  (allout-show-children))))))
     (let ((where (point)))
       (allout-rebullet-topic 1 (and (> arg 1) 'sans-offspring))
       (run-hook-with-args 'allout-structure-shifted-hook arg where))))
@@ -4382,13 +4391,12 @@
 					; region around subject:
   (if (< (allout-mark-marker t) (point))
       (exchange-point-and-mark))
-  (let* ( ;; inhibit aberrance doublecheck while reconciling disparate pastes:
-         (allout-during-yank-processing t)
-         (subj-beg (point))
+  (let* ((subj-beg (point))
          (into-bol (bolp))
          (subj-end (allout-mark-marker t))
          ;; 'resituate' if yanking an entire topic into topic header:
-         (resituate (and (allout-e-o-prefix-p)
+         (resituate (and (let ((allout-inhibit-aberrance-doublecheck t))
+                           (allout-e-o-prefix-p))
                          (looking-at allout-regexp)
                          (allout-prefix-data)))
          ;; `rectify-numbering' if resituating (where several topics may
@@ -4396,7 +4404,7 @@
          (rectify-numbering (or resituate
                                 (and into-bol (looking-at allout-regexp)))))
     (if resituate
-                                        ; The yanked stuff is a topic:
+        ;; Yanking a topic into the start of a topic - reconcile to fit:
         (let* ((inhibit-field-text-motion t)
                (prefix-len (if (not (match-end 1))
                                1
@@ -4466,7 +4474,8 @@
                    (progn
                      (delete-region (point) (+ (point)
                                                prefix-len
-                                               (- adjust-to-depth subj-depth)))
+                                               (- adjust-to-depth
+                                                  subj-depth)))
                                         ; and delete residual subj
                                         ; prefix digits and space:
                      (while (looking-at "[0-9]") (delete-char 1))
@@ -5880,6 +5889,10 @@
                                       target-prompt-id
                                     (or (buffer-file-name allout-buffer)
                                         target-prompt-id))))
+         (encoding (with-current-buffer allout-buffer
+                     buffer-file-coding-system))
+         (multibyte (with-current-buffer allout-buffer
+                     enable-multibyte-characters))
          (strip-plaintext-regexps
           (if (not decrypt)
               (allout-get-configvar-values
@@ -5916,6 +5929,13 @@
 
           (insert text)
 
+          ;; convey the text characteristics of the original buffer:
+          (set-buffer-multibyte multibyte)
+          (when encoding
+            (set-buffer-file-coding-system encoding)
+            (if (not decrypt)
+                (encode-coding-region (point-min) (point-max) encoding)))
+
           (when (and strip-plaintext-regexps (not decrypt))
             (dolist (re strip-plaintext-regexps)
               (let ((re (if (listp re) (car re) re))

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2006-11-06 15:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <877iyfjpbx.fsf@acm.org>
2006-11-01 18:07 ` Fwd: allout encryption and non-ascii characters Ken Manheimer
2006-11-01 18:33   ` Ken Manheimer
2006-11-04 19:28   ` Ken Manheimer
2006-11-06 15:56     ` Ken Manheimer [this message]
     [not found]       ` <87wt68yrcu.fsf@acm.org>
2006-11-07 23:22         ` Ken Manheimer
2006-11-08  0:13           ` Ken Manheimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cd46e7f0611060756k5f8caa92ocde9a2d24f907a8d@mail.gmail.com \
    --to=ken.manheimer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).