* files.el
@ 2004-03-18 4:32 Luc Teirlinck
2004-03-18 13:30 ` files.el Luc Teirlinck
0 siblings, 1 reply; 3+ messages in thread
From: Luc Teirlinck @ 2004-03-18 4:32 UTC (permalink / raw)
The function `insert-directory' is supposed to be able to handle both
a second argument that is a string of options _and_ a second argument
that is a list of strings of individual options. However, it
currently can not, as the ielm run below shows. The culprit is the
code that tries to treat the "--dired" option specially. I include a
patch that fixes the problem. I can install if desired.
ELISP> (set-buffer "*scratch*")
#<buffer *scratch*>
ELISP> (insert-directory "~" "-Al -t" nil t)
nil
ELISP> (insert-directory "~" '("-A" "-l") nil t)
*** Eval error *** Wrong type argument: stringp, ("-A" "-l")
ELISP>
===File ~/files.el-diff=====================================
*** files.el.~1.680.~ Thu Mar 4 15:36:49 2004
--- files.el Wed Mar 17 21:46:59 2004
***************
*** 4205,4218 ****
(defun insert-directory (file switches &optional wildcard full-directory-p)
"Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
! SWITCHES may be a string of options, or a list of strings.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.
This works by running a directory listing program
whose name is in the variable `insert-directory-program'.
! If WILDCARD, it also runs the shell specified by `shell-file-name'."
;; We need the directory in order to find the right handler.
(let ((handler (find-file-name-handler (expand-file-name file)
'insert-directory)))
--- 4205,4224 ----
(defun insert-directory (file switches &optional wildcard full-directory-p)
"Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
! SWITCHES may be a string of options, or a list of strings
! representing individual options.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.
This works by running a directory listing program
whose name is in the variable `insert-directory-program'.
! If WILDCARD, it also runs the shell specified by `shell-file-name'.
!
! When SWITCHES contains the long `--dired' option,this function
! treats it specially, for the sake of dired. However, the
! normally equivalent short `-D' option is just passed on to
! `insert-directory-program', as any other option."
;; We need the directory in order to find the right handler.
(let ((handler (find-file-name-handler (expand-file-name file)
'insert-directory)))
***************
*** 4301,4307 ****
(access-file file "Reading directory")
(error "Listing directory failed but `access-file' worked")))
! (when (string-match "--dired\\>" switches)
(forward-line -2)
(when (looking-at "//SUBDIRED//")
(delete-region (point) (progn (forward-line 1) (point)))
--- 4307,4318 ----
(access-file file "Reading directory")
(error "Listing directory failed but `access-file' worked")))
! (when (if (stringp switches)
! (string-match "--dired\\>" switches)
! (catch 'found
! (dolist (str switches)
! (when (string= "--dired" str)
! (throw 'found t)))))
(forward-line -2)
(when (looking-at "//SUBDIRED//")
(delete-region (point) (progn (forward-line 1) (point)))
============================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: files.el
2004-03-18 4:32 files.el Luc Teirlinck
@ 2004-03-18 13:30 ` Luc Teirlinck
0 siblings, 0 replies; 3+ messages in thread
From: Luc Teirlinck @ 2004-03-18 13:30 UTC (permalink / raw)
Cc: emacs-devel
The dolist loop in my previous patch was silly. I originally had
another condition than string=, for which the dolist was necessary.
When I replaced it with string=, I failed to notice that after that,
the dolist became essentially equivalent to member. Revised patch:
===File ~/files.el-diff=====================================
*** files.el.~1.680.~ Thu Mar 4 15:36:49 2004
--- files.el Thu Mar 18 07:18:56 2004
***************
*** 4205,4218 ****
(defun insert-directory (file switches &optional wildcard full-directory-p)
"Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
! SWITCHES may be a string of options, or a list of strings.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.
This works by running a directory listing program
whose name is in the variable `insert-directory-program'.
! If WILDCARD, it also runs the shell specified by `shell-file-name'."
;; We need the directory in order to find the right handler.
(let ((handler (find-file-name-handler (expand-file-name file)
'insert-directory)))
--- 4205,4224 ----
(defun insert-directory (file switches &optional wildcard full-directory-p)
"Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
! SWITCHES may be a string of options, or a list of strings
! representing individual options.
Optional third arg WILDCARD means treat FILE as shell wildcard.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.
This works by running a directory listing program
whose name is in the variable `insert-directory-program'.
! If WILDCARD, it also runs the shell specified by `shell-file-name'.
!
! When SWITCHES contains the long `--dired' option,this function
! treats it specially, for the sake of dired. However, the
! normally equivalent short `-D' option is just passed on to
! `insert-directory-program', as any other option."
;; We need the directory in order to find the right handler.
(let ((handler (find-file-name-handler (expand-file-name file)
'insert-directory)))
***************
*** 4225,4231 ****
;; Read the actual directory using `insert-directory-program'.
;; RESULT gets the status code.
! (let* (;; We at first read by no-conversion, then after
;; putting text property `dired-filename, decode one
;; bunch by one to preserve that property.
(coding-system-for-read 'no-conversion)
--- 4231,4237 ----
;; Read the actual directory using `insert-directory-program'.
;; RESULT gets the status code.
! (let* ( ;; We at first read by no-conversion, then after
;; putting text property `dired-filename, decode one
;; bunch by one to preserve that property.
(coding-system-for-read 'no-conversion)
***************
*** 4301,4307 ****
(access-file file "Reading directory")
(error "Listing directory failed but `access-file' worked")))
! (when (string-match "--dired\\>" switches)
(forward-line -2)
(when (looking-at "//SUBDIRED//")
(delete-region (point) (progn (forward-line 1) (point)))
--- 4307,4315 ----
(access-file file "Reading directory")
(error "Listing directory failed but `access-file' worked")))
! (when (if (stringp switches)
! (string-match "--dired\\>" switches)
! (member "--dired" switches))
(forward-line -2)
(when (looking-at "//SUBDIRED//")
(delete-region (point) (progn (forward-line 1) (point)))
============================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
* files.el
@ 2005-05-14 2:07 Luc Teirlinck
0 siblings, 0 replies; 3+ messages in thread
From: Luc Teirlinck @ 2005-05-14 2:07 UTC (permalink / raw)
Rev 1.765 of files.el introduced the new function
`hack-local-variables-confirm', but this was not mentioned in the ChangeLog:
* files.el (read-directory-name): Fix previous change.
Either the omission from the ChangeLog or the change itself must have
been inadvertent. I presume the former.
The change has two problems. If `enable-local-variables' is 'ask, it
_always_ asks the user about the -*- line, even when it actually is
going to process a local variables list or an eval or hook local
variable. Also, after the change, the former support for non-file
visiting buffers no longer works.
Put:
-*- mode: text; aa: 89; -*-
ahaha
Local Variables:
eval: (setq ww 345)
bb: 99
End:
in a file, and then visit that file in Emacs with
`enable-local-variables' set to 'ask. You get asked three times an
identical question.
Copy the same text in a non file visiting buffer and do, still with
enable-local-variables set to 'ask:
M-: (hack-local-variables)
An error results.
The patch below corrects all above problems. I can install if desired.
===File ~/files-diff========================================
*** files.el 13 May 2005 19:25:16 -0500 1.769
--- files.el 13 May 2005 20:05:31 -0500
***************
*** 2152,2158 ****
(goto-char beg)
end))))
! (defun hack-local-variables-confirm ()
(or (eq enable-local-variables t)
(and enable-local-variables
(save-window-excursion
--- 2152,2158 ----
(goto-char beg)
end))))
! (defun hack-local-variables-confirm (string)
(or (eq enable-local-variables t)
(and enable-local-variables
(save-window-excursion
***************
*** 2169,2176 ****
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
! (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
! (file-name-nondirectory buffer-file-name)))))))
(defun hack-local-variables-prop-line (&optional mode-only)
"Set local variables specified in the -*- line.
--- 2169,2178 ----
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
! (y-or-n-p (format string
! (if buffer-file-name
! (file-name-nondirectory buffer-file-name)
! (concat "buffer " (buffer-name)))))))))
(defun hack-local-variables-prop-line (&optional mode-only)
"Set local variables specified in the -*- line.
***************
*** 2226,2232 ****
(if mode-only mode-specified
(if (and result
(or mode-only
! (hack-local-variables-confirm)))
(let ((enable-local-eval enable-local-eval))
(while result
(hack-one-local-variable (car (car result)) (cdr (car result)))
--- 2228,2235 ----
(if mode-only mode-specified
(if (and result
(or mode-only
! (hack-local-variables-confirm
! "Set local variables as specified in -*- line of %s? ")))
(let ((enable-local-eval enable-local-eval))
(while result
(hack-one-local-variable (car (car result)) (cdr (car result)))
***************
*** 2256,2262 ****
(when (let ((case-fold-search t))
(and (search-forward "Local Variables:" nil t)
(or mode-only
! (hack-local-variables-confirm))))
(skip-chars-forward " \t")
(let ((enable-local-eval enable-local-eval)
;; suffix is what comes after "local variables:" in its line.
--- 2259,2266 ----
(when (let ((case-fold-search t))
(and (search-forward "Local Variables:" nil t)
(or mode-only
! (hack-local-variables-confirm
! "Set local variables as specified at end of %s? "))))
(skip-chars-forward " \t")
(let ((enable-local-eval enable-local-eval)
;; suffix is what comes after "local variables:" in its line.
***************
*** 2477,2483 ****
(hack-one-local-variable-eval-safep val))
;; Permit eval if not root and user says ok.
(and (not (zerop (user-uid)))
! (hack-local-variables-confirm)))
(if (eq var 'eval)
(save-excursion (eval val))
(make-local-variable var)
--- 2481,2488 ----
(hack-one-local-variable-eval-safep val))
;; Permit eval if not root and user says ok.
(and (not (zerop (user-uid)))
! (hack-local-variables-confirm
! "Process `eval' or hook local variables in %s? ")))
(if (eq var 'eval)
(save-excursion (eval val))
(make-local-variable var)
============================================================
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-05-14 2:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-18 4:32 files.el Luc Teirlinck
2004-03-18 13:30 ` files.el Luc Teirlinck
-- strict thread matches above, loose matches on Subject: below --
2005-05-14 2:07 files.el Luc Teirlinck
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.