Christoph | 31 Aug 20:45 2014
Picon

Removing mode-specific window restore code

Some modes have their own quit function, which buries/kill buffer and often times also restores the window configuration from its own internally stored variables or runs specific cleanup code.

Previous discussion here:

First, I would like to try to remove the mode-specific window restore code and let `quit-window' handle this.

One low-hanging example (unless I am missing anything) is in ibuffer.el.

Using `quit-window' also allows to kill the buffer with `C-u q', which is new behavior for `ibuffer', but align with other modes.

Next, I would like to look at modes that do "other stuff" in their respective `quit' function. This goes back to the `quit-window-hook' discussion in the above mentioned thread. This also includes modes that just plainly call `bury-buffer' without restoring window configuration instead of `quit-window' upon quitting the mode.

Should I open bug reports for each instance to track the review or post patches here?

ibuffer patch, comments welcome:

=== modified file 'lisp/ibuffer.el'
--- lisp/ibuffer.el 2014-08-08 14:35:40 +0000
+++ lisp/ibuffer.el 2014-08-31 17:26:11 +0000
<at> <at> -540,7 +540,7 <at> <at>
     (define-key map (kbd "/ X") 'ibuffer-delete-saved-filter-groups)
     (define-key map (kbd "/ \\") 'ibuffer-clear-filter-groups)
 
-    (define-key map (kbd "q") 'ibuffer-quit)
+    (define-key map (kbd "q") 'quit-window)
     (define-key map (kbd "h") 'describe-mode)
     (define-key map (kbd "?") 'describe-mode)
 
<at> <at> -878,12 +878,6 <at> <at>
     (define-key map [down-mouse-3] 'ibuffer-mouse-popup-menu)
     map))
 
-(defvar ibuffer-restore-window-config-on-quit nil
-  "If non-nil, restore previous window configuration upon exiting `ibuffer'.")
-
-(defvar ibuffer-prev-window-config nil
-  "Window configuration before starting Ibuffer.")
-
 (defvar ibuffer-did-modification nil)
 
 (defvar ibuffer-compiled-formats nil)
<at> <at> -2298,18 +2292,6 <at> <at>
       (goto-char (point-min))
       (forward-line orig))))
 
-(defun ibuffer-quit ()
-  "Quit this `ibuffer' session.
-Try to restore the previous window configuration if
-`ibuffer-restore-window-config-on-quit' is non-nil."
-  (interactive)
-  (if ibuffer-restore-window-config-on-quit
-      (progn
- (bury-buffer)
- (unless (= (count-windows) 1)
-  (set-window-configuration ibuffer-prev-window-config)))
-    (bury-buffer)))
-
 ;;;###autoload
 (defun ibuffer-list-buffers (&optional files-only)
   "Display a list of buffers, in another window.
<at> <at> -2350,7 +2332,6 <at> <at>
   (interactive "P")
   (when ibuffer-use-other-window
     (setq other-window-p t))
-  (setq ibuffer-prev-window-config (current-window-configuration))
   (let ((buf (get-buffer-create (or name "*Ibuffer*"))))
     (if other-window-p
  (funcall (if noselect (lambda (buf) (display-buffer buf t)) #'pop-to-buffer) buf)
<at> <at> -2362,8 +2343,7 <at> <at>
  (select-window (get-buffer-window buf 0))
  (or (derived-mode-p 'ibuffer-mode)
     (ibuffer-mode))
- (setq ibuffer-restore-window-config-on-quit other-window-p)
- (when shrink
+ (when shrink
   (setq ibuffer-shrink-to-minimum-size shrink))
  (when qualifiers
   (require 'ibuf-ext)
<at> <at> -2501,7 +2481,6 <at> <at>
   '\\[ibuffer-switch-format]' - Change the current display format.
   '\\[forward-line]' - Move point to the next line.
   '\\[previous-line]' - Move point to the previous line.
-  '\\[ibuffer-quit]' - Bury the Ibuffer buffer.
   '\\[describe-mode]' - This help.
   '\\[ibuffer-diff-with-file]' - View the differences between this buffer
           and its associated file.
<at> <at> -2616,7 +2595,6 <at> <at>
   (set (make-local-variable 'ibuffer-cached-eliding-string) nil)
   (set (make-local-variable 'ibuffer-cached-elide-long-columns) nil)
   (set (make-local-variable 'ibuffer-current-format) nil)
-  (set (make-local-variable 'ibuffer-restore-window-config-on-quit) nil)
   (set (make-local-variable 'ibuffer-did-modification) nil)
   (set (make-local-variable 'ibuffer-tmp-hide-regexps) nil)
   (set (make-local-variable 'ibuffer-tmp-show-regexps) nil)

Ivan Kanis | 30 Aug 11:42 2014
Face
Picon

math round woes

Hello,

I am having problem this week with org-drill failing due to a rounding
error.

(round 586514472.354) -> eval: Arithmetic range error: "round",
586514472.354

I thought I'd patch things with calc:

(require 'calc-arith)
(math-round 586514472.354) -> 586514472.354

I looked at math-round and it calls math-trunk:

(math-trunk 1.1) -> 1.1

What's going on?

I am on the emacs-24 branch.
--

-- 
Static from nylon underwear.
    -- BOFH excuse #57

Perry E. Metzger | 29 Aug 16:18 2014

Non-ASCII chars in quail rules

This is an elisp question, and it *seemed* more appropriate on the
devel list, but if I'm wrong, I'll move the question elsewhere.

Briefly, my problem is this: my caps lock key is never used for
anything on my keyboard, and I thought it might be cool to use it
as a poor man's compose key for entering non-ASCII characters.

I mapped it to F19 and then set that to insert the Unicode character
for the Compose glyph (U+2384) thinking it would be especially
appropriate.

I then realized that "quail-define-rules" really doesn't play well
with KEY strings that aren't pure ASCII.

1) Is there any easy way to fix that? Simply removing the < 127 test
in the code that builds the maps doesn't work. (I'm afraid I don't
fully understand where the maps are used, which is probably a
problem.)

2) If there isn't an easy way to fix that, is there any obvious
simple way to build an input method that either signals the beginning
of a translated series of characters either with a non-ASCII character
(like U+2384) or with a function key like F19 directly?

I note that essentially the only way of building input methods these
days seems to be quail, or at least, almost all the shipped methods
use quail.

BTW, if it isn't obvious, yes, I could just set the key to enter some
ASCII character (see the rfc1345 input method for example) but my
goal here is to *not* require anything special to enter normal ASCII
but to use the caps lock key as some sort of compose key.

Perry
--

-- 
Perry E. Metzger		perry <at> piermont.com

Eli Zaretskii | 29 Aug 12:46 2014
Picon

[Emacs-diffs] trunk r117765: Add vectors support to Fsort.

Thanks for doing this.

This change should have a corresponding NEWS entry.

Eli Zaretskii | 29 Aug 11:53 2014
Picon

Re: Changes in frame/window code

> Date: Fri, 29 Aug 2014 11:00:31 +0200
> From: martin rudalics <rudalics <at> gmx.at>
> CC: emacs-devel <at> gnu.org
> 
>  > You mean, that "a" on the right fringe of the rightmost window?
>  > That's entirely unrelated to the problems I fixed in r117417.
> 
> Visually they are very similar.

No, they aren't: what you see on the fringe is always a remnant of a
cursor -- it's always in cursor colors, not the text colors.

IOW, something draws the cursor on the fringe, or maybe scrolls text
with the cursor on it, as drawn by the previous redisplay, without
paying attention to the fact that the x-coordinate is outside the text
area.

By contrast, the problems fixed in r117417 were due to incorrect setup
of the glyph row in the text area, not to incorrect drawing.

> (1) C-u C-h t hebrew RET
> 
> (2) C-x 3                              (gives hscroll-0.png)
> 
> (3) M-: (set-window-hscroll nil 1)     (gives hscroll-1.png)
> 
> (4) M-: (set-window-hscroll nil 2)     (gives hscroll-2.png)
> 
> (5) M-: (set-window-hscroll nil 1)     (gives hscroll-3.png)
> 
> Note again: NOT reproducible on my Windows build.

I think I can reproduce something similar if I change the buffer font
size from the default.

Thanks, I will take a look.

Drew Adams | 28 Aug 23:18 2014
Picon

feature request: text property to prevent font-locking

Excuse me if I'm missing something that is already available.
And in that case, please let me know what it is, so I can use it.

I want to apply some ad-hoc highlighting with text property `face'
in a font-locked buffer (whether font-locking occurs before or after
I apply `face' for this highlighting).

I do not want font-lock to override this highlighting.  I do not want
to use `font-lock-keywords' (e.g. with KEEP) in order to create this
highlighting.  I just want to prevent font-lock from overriding it.

I want to apply some other text property to the highlighted text, to
tell font-lock not to fiddle with it ("hands off this text").

1. Does this possibility already exist in Emacs?  I looked but didn't
   find anything.

2. If not, can we please add it?

Wrt #2:

Years ago I added this feature to code that I use.  It works for me,
but I don't claim that the way I implemented it is the way to go.

The code I use is here:
http://www.emacswiki.org/emacs-en/download/font-lock%2b.el

Essentially I did this:

1. Defined function `put-text-property-unless-ignore', which is the
   same as `put-text-property' but ignores text that has property
   `font-lock-ignore'.

2. Redefined function `font-lock-default-unfontify-region' to not
   unfontify text that has property `font-lock-ignore',

3. Redefined these functions to use `put-text-property-unless-ignore'
   instead of `put-text-property':

   font-lock-prepend-text-property
   font-lock-append-text-property
   font-lock-fillin-text-property
   font-lock-apply-syntactic-highlight
   font-lock-fontify-syntactically-region
   font-lock-apply-highlight
   font-lock-fontify-anchored-keywords
   font-lock-fontify-keywords-region

   That is, the change to each of these functions is ONLY to use
   `put-text-property-unless-ignore' instead of `put-text-property'.

My implementation of `put-text-property-unless-ignore':

(defun put-text-property-unless-ignore (start end property value
                                        &optional object)
  "`put-text-property', but ignore text with property `font-lock-ignore'."
  (let ((here  (min start end))
        (end1  (max start end))
        chg)
    (while (< here end1)
      (setq chg  (next-single-property-change here 'font-lock-ignore
                                              object end1))
      (unless (get-text-property here 'font-lock-ignore object)
        (put-text-property here chg property value object))
      (setq here  chg))))

Perhaps there is a better way to do this.  Dunno.

In any case, my request is just for Emacs to have such a feature,
however it might be implemented.  Even better would be an answer that
Emacs already has something like this that I'm unaware of.

I use this feature for various highlighting (and unhighlighting)
commands, so that the highlighting works for font-locked text too.
This includes `facemenu-add-face' (my version).

Ken Brown | 27 Aug 19:15 2014
Picon

Gnulib ACL wrappers

Paul,

This is a followup to a discussion on the Cygwin list.  See 
https://cygwin.com/ml/cygwin/2014-08/msg00531.html, and perhaps one or 
two earlier messages in the thread if you need more context.

Although Cygwin has Solaris ACL functions, emacs doesn't use these in 
fileio.c.  Shouldn't the Gnulib ACL wrappers provide support for these? 
  Or is there something needed in Cygwin to make this work?

Here's what's in config.h concerning ACLs:

#define EMACS_CONFIG_FEATURES "DBUS ACL GNUTLS LIBXML2 ZLIB"
/* #undef HAVE_ACLSORT */
/* #undef HAVE_ACLV_H */
/* #undef HAVE_ACLX_GET */
/* #undef HAVE_ACL_COPY_EXT_NATIVE */
/* #undef HAVE_ACL_CREATE_ENTRY_NP */
/* #undef HAVE_ACL_DELETE_DEF_FILE */
/* #undef HAVE_ACL_DELETE_FD_NP */
/* #undef HAVE_ACL_DELETE_FILE_NP */
/* #undef HAVE_ACL_ENTRIES */
/* #undef HAVE_ACL_EXTENDED_FILE */
/* #undef HAVE_ACL_FIRST_ENTRY */
/* #undef HAVE_ACL_FREE */
/* #undef HAVE_ACL_FREE_TEXT */
/* #undef HAVE_ACL_FROM_MODE */
/* #undef HAVE_ACL_FROM_TEXT */
/* #undef HAVE_ACL_GET_FD */
/* #undef HAVE_ACL_GET_FILE */
/* #undef HAVE_ACL_LIBACL_H */
/* #undef HAVE_ACL_SET_FD */
/* #undef HAVE_ACL_SET_FILE */
/* #undef HAVE_ACL_TO_SHORT_TEXT */
/* #undef HAVE_ACL_TRIVIAL */
/* #undef HAVE_ACL_TYPE_EXTENDED */
#define HAVE_FACL 1
/* #undef HAVE_GETACL */
/* #undef HAVE_STATACL */
#define HAVE_SYS_ACL_H 1
#define USE_ACL 1

Ken

Dmitry Antipov | 27 Aug 15:09 2014
Picon

Unused/obsolete `last-code-conversion-error'?

AFAICS `last-code-conversion-error' is untouched and unused since 2009
(probably it was never really used), and maintaining it just adds some
overhead to important coding.c routines.  OK to install something like this?

Dmitry
Alan Schmitt | 27 Aug 08:45 2014

Small patch for gnus nnimap.el

Hello,

I posted this on gnus.general a couple weeks ago, but nobody
replied. I'm thus wondering if emacs.devel might be a better place to
send gnus patches. If not, could you please direct me to the correct
place?

As I'm trying to make the registry working with expiration, I think
I found a bug in nnimap.el. Here is the code in question.

#+begin_src emacs-lisp
(defun nnimap-process-expiry-targets (articles group server)
  (let ((deleted-articles nil))
    (cond
     ;; shortcut further processing if we're going to delete the articles
     ((eq nnmail-expiry-target 'delete)
      (setq deleted-articles articles)
      t)
     ;; or just move them to another folder on the same IMAP server
     ((and (not (functionp nnmail-expiry-target))
	   (gnus-server-equal (gnus-group-method nnmail-expiry-target)
			      (gnus-server-to-method
			       (format "nnimap:%s" server))))
      (and (nnimap-change-group group server)
	   (with-current-buffer (nnimap-buffer)
	     (nnheader-message 7 "Expiring articles from %s: %s" group articles)
	     (nnimap-command
	      "UID COPY %s %S"
	      (nnimap-article-ranges (gnus-compress-sequence articles))
	      (utf7-encode (gnus-group-real-name nnmail-expiry-target) t))
	     (setq deleted-articles articles)))
      t)
     (t
      (dolist (article articles)
	(let ((target nnmail-expiry-target))
	  (with-temp-buffer
	    (mm-disable-multibyte)
	    (when (nnimap-request-article article group server (current-buffer))
	      (when (functionp target)
		(setq target (funcall target group)))
	      (if (and target
		       (not (eq target 'delete)))
		  (if (or (gnus-request-group target t)
			  (gnus-request-create-group target))
		      (progn
			(nnmail-expiry-target-group target group)
			(nnheader-message 7 "Expiring article %s:%d to %s"
					  group article target))
		    (setq target nil))
		(nnheader-message 7 "Expiring article %s:%d" group article))
	      (when target
		(push article deleted-articles))))))))
    ;; Change back to the current group again.
    (nnimap-change-group group server)
    (setq deleted-articles (nreverse deleted-articles))
    (nnimap-delete-article (gnus-compress-sequence deleted-articles))
    deleted-articles))
#+end_src

The result of this function should be a list or messages that have been
deleted, ordered by '<' (since 'gnus-sorted-complement' is then called
on that list). If articles are deleted or sent to a static group on the
same server, then 'deleted-articles' is just set to the list of all
articles to expire. Otherwise each article is considered in turn, and
articles that were successfully moved are put in the deleted-articles
list.

The problem with this function is that the list of deleted articles is
reversed in every case, but it should only be reversed in the last case
(when it was created considering each article in turn and pushing it
onto the list, thus creating it in reverse). Attached is a patch fixing
this.

As an example why the current behavior is wrong, here is part of
a debugging session:

> Result: (4402 4406 4409 4414 4415)
> 
> Result: "work"
> 
> Expiring articles from work: (4402 4406 4415)
> Result: (4402 4406 4409 4414 4406 4402)

The first list is the list of all articles to consider. Then the
articles "(4402 4406 4415)" are expired, and the result should be the
remaining articles. Here the list of expired articles was reversed, and
when taking the complement only 4415 was removed (since it's assumed
it's ordered by '<') and the other remaining articles were put at the
end.

If you agree with this analysis, could you please apply this patch?

I have a question about the code above. Why do the first two cases of
the cond return a 't' at the end?

Thanks,

Alan


--

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Drew Adams | 25 Aug 22:07 2014
Picon

Why was `transient-mark-mode' turned off for `delete-selection-mode'?

I came across this item in NEWS:

** Delete Selection mode can now be used without Transient Mark mode.

"Can now be"?  That sounds positive, as if we are adding some new
possibility that is useful.  Are we?

Why would we do this - what is the use case?  Why should
`delete-selection-mode' no longer enable transient-mark-mode'?

Have we had requests from users who turn off `transient-mark-mode',
asking to be able to use `delete-selection-mode' without seeing
the selection?

I've searched a bit for a discussion about this, in emacs-devel and
in the bug list, but I didn't find anything related.  I searched around
the time of the change, which was apparently made on 2013-12-11, with
this commit:
http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/115459

Stefan Monnier2013-12-11 14:42:34
Revision ID: monnier <at> iro.umontreal.ca-20131211144234-evm5nwt04uoggorp
* lisp/delsel.el (delete-selection-mode): Don't enable transient-mark-mode.
(delete-selection-helper): Make sure yank starts at the top of the
deleted region.
(minibuffer-keyboard-quit): Use region-active-p.

So far, this change doesn't sound like a very good idea to me, but I
would like to know more about it, in particular the rationale for it.  

Delete selection mode has always been about providing similar
delete/replace-the-selection behavior to what is prevalent outside
Emacs. Why would we now divorce this behavior from highlighting of
the selection?

Dmitry Antipov | 25 Aug 16:46 2014
Picon

[RFC] sigaltstack + longjmp to protect from C stack overflow

This is an experimental and most probably non-portable method to handle
C stack overflow by using well-known sigaltstack/siglongjmp approach.
This can help if someone do something like:

(setq max-specpdl-size 83200000
       max-lisp-eval-depth 640000)

(defun f1 () (f1))

(f1) ==> Re-entering top level after C stack overflow

Comments?

Dmitry
Attachment (c_stack_overflow.patch): text/x-patch, 4908 bytes

Gmane