Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4270514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:19:00+00:00 2026-05-21T07:19:00+00:00

I looking for the function that prints file size on the mode-line in size-indication-mode.

  • 0

I looking for the function that prints file size on the mode-line in size-indication-mode. I have searched for size-indication-mode in the source but cannot find a code-references to it. So where is the function that prints for example
22k

when file is approximately 22 kilobytes big?

What about difference between
– kilobytes (kB), 1000 bytes, and
– kibibytes (KiB), 1024 bytes, as defined at

Shouldn’t Emacs support both?

This is of course not that hard to write but why reinvent the wheel?

http://en.wikipedia.org/wiki/Kibibyte

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:19:01+00:00Added an answer on May 21, 2026 at 7:19 am

    Here’s the function I use.

    (defconst number-to-string-approx-suffixes
      '("k" "M" "G" "T" "P" "E" "Z" "Y"))
    (defun number-to-string-approx-suffix (n &optional binary)
      "Return an approximate decimal representation of NUMBER as a string,
    followed by a multiplier suffix (k, M, G, T, P, E, Z, Y). The representation
    is at most 5 characters long for numbers between 0 and 10^19-5*10^16.
    Uses a minus sign if negative.
    NUMBER may be an integer or a floating point number.
    If the optional argument BINARY is non-nil, use 1024 instead of 1000 as
    the base multiplier."
      (if (zerop n)
          "0"
        (let ((sign "")
              (b (if binary 1024 1000))
              (suffix "")
              (bigger-suffixes number-to-string-approx-suffixes))
          (if (< n 0)
              (setq n (- n)
                    sign "-"))
          (while (and (>= n 9999.5) (consp bigger-suffixes))
            (setq n (/ n b) ; TODO: this is rounding down; nearest would be better
                  suffix (car bigger-suffixes)
                  bigger-suffixes (cdr bigger-suffixes)))
          (concat sign
                      (if (integerp n)
                      (int-to-string n)
                    (number-to-string (floor n)))
                  suffix))))
    

    I use it in the size column of the buffer menu.

    (defvar Buffer-menu-buffer+size-shorten 'binary)
    (defadvice Buffer-menu-buffer+size (before Buffer-menu-shorten-size
                                        compile activate)
      "Shorten the size column in a buffer menu by using multiplier suffixes
    \(k, M, G, T\).
    This is done only if `Buffer-menu-buffer+size-shorten' is non-nil.
    If `Buffer-menu-buffer+size-shorten' is the symbol `binary', use binary
    multipliers (powers of 1024). Otherwise use decimal (powers of 1000)
    multipliers."
      (if Buffer-menu-buffer+size-shorten
          (let ((binary (eq Buffer-menu-buffer+size-shorten 'binary)))
            (save-match-data
              (if (string-match "^[0-9]+$" size)
                  (setq size (number-to-string-approx-suffix (string-to-number size)
                                                             binary)))))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'me looking for a function that would receive a time and would round it
I'm looking for a function that calculates years from a date in format: 0000-00-00.
I am looking for a function that would be the alphabetic equivalent of is_numeric.
I am looking for a function that will tell me, for a list of
I am Looking for a Function that insert Any form values to mysql ,
Original Question I am looking for a function that attempts to quantify how distant
Similar in concept to Math.Abs() - I'm looking for a function that when given
I am not that familiar with Javascript, and am looking for the function that
I'm looking to implement a function that retrieves a single frame from an input
I'm looking for a hash function that: Hashes textual strings well (e.g. few collisions)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.