* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
@ 2016-03-03 5:58 Lars Ingebrigtsen
2016-03-04 13:39 ` Lars Ingebrigtsen
0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2016-03-03 5:58 UTC (permalink / raw)
To: 22890
`file-attributes' returns a list of data, and you very often see code
like
(let ((atts (file-attributes file)))
(when (> (elt atts 7) 4000)
...))
and you have no idea what that means. So I think there should be 12
attribute accessor functions (well, defsubsts) that people can use
instead. The names could be something like `file-attribute-size',
`file-attribute-access-time', etc.
In GNU Emacs 25.1.50.65 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.7)
of 2016-03-03 built on mouse
Repository revision: 0c5c04d58e4efc04905a3f42e984d5f24c554a34
Windowing system distributor 'The X.Org Foundation', version 11.0.11702000
System Description: Ubuntu 15.10
Configured using:
'configure --with-xwidgets --with-x-toolkit=gtk3'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XWIDGETS
Important settings:
value of $LC_MONETARY: nb_NO.UTF-8
value of $LC_NUMERIC: nb_NO.UTF-8
value of $LC_TIME: nb_NO.UTF-8
value of $LANG: C
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: Group
Minor modes in effect:
diff-auto-refine-mode: t
gnus-topic-mode: t
gnus-undo-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
Recent messages:
Sending via mail...
Sending email
Sending email done
Mark set
Saving file /home/larsi/Mail/archive/sent/2016w09...
Wrote /home/larsi/Mail/archive/sent/2016w09
Sending...done
Making completion list... [2 times]
Type C-x 1 to delete the help window, C-M-v to scroll help.
Making completion list...
Load-path shadows:
~/src/emacs/elpa/packages/debbugs/debbugs-org hides /home/larsi/.emacs.d/elpa/debbugs-0.7/debbugs-org
~/src/emacs/elpa/packages/debbugs/debbugs-browse hides /home/larsi/.emacs.d/elpa/debbugs-0.7/debbugs-browse
~/src/emacs/elpa/packages/debbugs/debbugs-gnu hides /home/larsi/.emacs.d/elpa/debbugs-0.7/debbugs-gnu
~/src/emacs/elpa/packages/debbugs/debbugs hides /home/larsi/.emacs.d/elpa/debbugs-0.7/debbugs
Features:
(shadow emacsbug eieio-opt speedbar sb-image ezimage dframe find-func
timezone eww iso-transl tabify misearch multi-isearch shr-color color
mailalias smtpmail sendmail ecomplete log-edit ring pcvs-util vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs vc-dir ewoc copyright bug-reference
whitespace vc vc-dispatcher vc-git map diff-mode gnus-html help-fns qp
url-queue url-cache mm-archive sort smiley ansi-color gnus-cite
gnus-async gnus-dup gnus-ml gmane spam-gmane dns mm-url disp-table
gnus-fun gnus-mdrtn nndraft nnmh utf-7 gnus-topic nnfolder
network-stream nsm starttls nnir spam-report spam spam-stat gnus-uu yenc
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art
mm-uu mml2015 mm-view mml-smime smime dig nntp gnus-cache gnus-sum
gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source
utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message
format-spec rfc822 mml mml-sec epa epg mailabbrev gmm-utils mailheader
gnus-win gnus nnheader gnus-util rmail rmail-loaddefs mail-utils
wid-edit movie mkv shr svg browse-url imdb dom pvr debug debbugs-gnu
easy-mmode derived subr-x debbugs soap-client mm-decode mm-bodies
mm-encode url-http tls gnutls url-auth mail-parse rfc2231 rfc2047
rfc2045 ietf-drums url-gw puny url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap warnings
rng-xsd rng-dt rng-util xsd-regexp xml ido seq flyspell ispell dired
dired-loaddefs add-log mail-extr mm-util mail-prsvr jka-compr cl
finder-inf info package epg-config url-handlers url-parse auth-source
cl-seq eieio byte-opt bytecomp byte-compile cl-extra help-mode easymenu
cconv eieio-core cl-macs gv eieio-loaddefs cl-loaddefs pcase cl-lib
password-cache url-vars time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting xwidget-internal move-toolbar
gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 612056 52571)
(symbols 48 163800 2)
(miscs 40 444 1918)
(strings 32 232021 8136)
(string-bytes 1 8667448)
(vectors 16 40998)
(vector-slots 8 1738164 271804)
(floats 8 771 2486)
(intervals 56 6959 1064)
(buffers 976 58)
(heap 1024 205225 83336))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
2016-03-03 5:58 bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors Lars Ingebrigtsen
@ 2016-03-04 13:39 ` Lars Ingebrigtsen
2016-03-04 16:17 ` Andy Moreton
0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2016-03-04 13:39 UTC (permalink / raw)
To: 22890
Lars Ingebrigtsen <larsi@gnus.org> writes:
> `file-attributes' returns a list of data, and you very often see code
> like
>
> (let ((atts (file-attributes file)))
> (when (> (elt atts 7) 4000)
> ...))
>
> and you have no idea what that means. So I think there should be 12
> attribute accessor functions (well, defsubsts) that people can use
> instead. The names could be something like `file-attribute-size',
> `file-attribute-access-time', etc.
I've now implemented this on the trunk.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
2016-03-04 13:39 ` Lars Ingebrigtsen
@ 2016-03-04 16:17 ` Andy Moreton
2016-03-04 19:25 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 7+ messages in thread
From: Andy Moreton @ 2016-03-04 16:17 UTC (permalink / raw)
To: 22890
On Fri 04 Mar 2016, Lars Ingebrigtsen wrote:
> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> `file-attributes' returns a list of data, and you very often see code
>> like
>>
>> (let ((atts (file-attributes file)))
>> (when (> (elt atts 7) 4000)
>> ...))
>>
>> and you have no idea what that means. So I think there should be 12
>> attribute accessor functions (well, defsubsts) that people can use
>> instead. The names could be something like `file-attribute-size',
>> `file-attribute-access-time', etc.
>
> I've now implemented this on the trunk.
A useful addition. Please fix the defsubst typos (ntf -> nth) and
possibly add some tests.
Consider also fixing file-attributes callers to use the new accessors.
AndyM
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
2016-03-04 16:17 ` Andy Moreton
@ 2016-03-04 19:25 ` Lars Magne Ingebrigtsen
2016-03-04 19:51 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 2016-03-04 19:25 UTC (permalink / raw)
To: Andy Moreton; +Cc: 22890
Andy Moreton <andrewjmoreton@gmail.com> writes:
> Consider also fixing file-attributes callers to use the new accessors.
Is there a way to get the byte compiler to output warnings about using
`nth' on output from `file-attributes'? That would be awesome. But I
would guess not. But grepping for "nth.*file-attributes" gives us 180
matches, so somebody who wants to start fixing could... start... :-)
Anyway, we probably shouldn't do anything wholesale until 25.1 has been
released (to make merging easier).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
2016-03-04 19:25 ` Lars Magne Ingebrigtsen
@ 2016-03-04 19:51 ` Drew Adams
2016-03-04 20:00 ` John Wiegley
0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2016-03-04 19:51 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen, Andy Moreton; +Cc: 22890
> Is there a way to get the byte compiler to output warnings about
> using `nth' on output from `file-attributes'? That would be awesome.
It would not be awesome. It would be annoying.
There is nothing to WARN about here.
If you want to control usage for internal Emacs Dev
code then do just that. But for Emacs-Lisp users
in general this would be completely inappropriate.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
2016-03-04 19:51 ` Drew Adams
@ 2016-03-04 20:00 ` John Wiegley
2016-03-04 20:20 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: John Wiegley @ 2016-03-04 20:00 UTC (permalink / raw)
To: Drew Adams; +Cc: 22890, Lars Magne Ingebrigtsen, Andy Moreton
>>>>> Drew Adams <drew.adams@oracle.com> writes:
>> Is there a way to get the byte compiler to output warnings about using
>> `nth' on output from `file-attributes'? That would be awesome.
> It would not be awesome. It would be annoying. There is nothing to WARN
> about here.
You could add something of that effect to elint, for example. I'm not sure if
elint supports "level", or disabling certain warnings, but if it's bad style,
it would be nice to have an indication of it in a non-intrusive way.
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors
2016-03-04 20:00 ` John Wiegley
@ 2016-03-04 20:20 ` Drew Adams
0 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2016-03-04 20:20 UTC (permalink / raw)
To: John Wiegley; +Cc: 22890, Lars Magne Ingebrigtsen, Andy Moreton
> >> Is there a way to get the byte compiler to output warnings about
> >> using `nth' on output from `file-attributes'? That would be awesome.
>
> > It would not be awesome. It would be annoying. There is nothing to
> > WARN about here.
>
> You could add something of that effect to elint, for example. I'm
> not sure if elint supports "level", or disabling certain warnings,
> but if it's bad style, it would be nice to have an indication of it
> in a non-intrusive way.
Yes. Provide it as an (opt-in) option or a command or some other
way for users to get such information on demand. It's good to be
able to _ask_ for lint-like checks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-03-04 20:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03 5:58 bug#22890: 25.1.50; Wishlist: There should be file-attribute accessors Lars Ingebrigtsen
2016-03-04 13:39 ` Lars Ingebrigtsen
2016-03-04 16:17 ` Andy Moreton
2016-03-04 19:25 ` Lars Magne Ingebrigtsen
2016-03-04 19:51 ` Drew Adams
2016-03-04 20:00 ` John Wiegley
2016-03-04 20:20 ` Drew Adams
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).