texts: How to force the current line to be always in the middle of the screen

texts: I am editing a large file.  I would like the current line where the cursor is at to be always in the middle of the screen. Is this possible?


texts: remembering auth details for excorporate with .netrc

texts:
I've set up excorporate mode so that I can use emacs to read my outlook calendar.  However I am annoyed by having to input a username/password every time I open emacs.  I tried a .netrc:

machine outlook.office365.com login me@somewhere.com password 'secret'

But it doesn't work.  Can anyone point me further in the right direction?


texts:
I wonder if there is any easy way to configure effort selection dialogue to allow selecting effort value from the list using single key.
Currently I have configured Effort_ALL in the following way:
(add-to-list 'org-global-properties
         '("Effort_ALL". "0:05 0:15 0:30 1:00 2:00"))

and am using org-set-effort to pop up the dialogue. However the dialogue that it shows is just a regular narrow-list-of-candidates dialogue which takes multiple keystrokes (either arrows or partial string followed by return) to select the option I need.
What I would rather have instead is a org-fast-tag-selection-single-key-style dialogue that allows to select an entry from the list by just pressing a single button (e.g. 1, 2, 3, etc).
I've tried to look at the code for the org-set-effort and google for the ivy-like list-narrowing modules, but so far wasn't able to find much.


texts:
I'd like to run mu4e in a dedicated frame but on the same emacs server. The following function gets me almost there:

(defun malb/mail ()
  (interactive)
 (select-frame (make-frame-command))
 (toggle-frame-maximized) ;; HACK, I usually run maximised
 (sleep-for 0.1) ;; this is a HACK
 (set-frame-size (selected-frame) 200 64)
 (mu4e))

That is, it creates a new frame in which mu4e is started. However, that frame is just like any other emacs frame and might visit any buffer when I close a buffer created by mu4e. How can I dedicate this frame to mu4e and mu4e only?


texts:
I am able to open a remote C source file using tramp (via ssh). However, when I try to debug it using

M-x gdb
gdb -i=mi /ssh:localhost#8022:/usr/bin/httrack

I get

Current directory is /ssh:localhost#8022:/usr/bin/
Error: you did not specify -i
Debugger exited abnormally with code 127


texts: Make `insert` follow `(delete-selection-mode t)`

texts:
When I call helm-copy-to-buffer (which calls insert) with active region in my current buffer, the marked helm candidate is added after the active region.  But I expect the active region to be replaced by the helm candidate, as I had (delete-selection-mode t) in my init.el.

I tried to fix it by following advice:

(defun delete-region-before-insert (orig-fun &rest args) (cl-letf (((symbol-function 'insert) (lambda (arg) (if (region-active-p) (delete-region (region-beginning) (region-end))) (insert arg)))) (apply orig-fun args)))
(advice-add 'helm-copy-to-buffer :around #'delete-region-before-insert)

But it doesn't change anything, so I have to redefine helm-copy-to-buffer to fix it:

(defun helm-copy-to-buffer ()
  "Copy selection or marked candidates to `helm-current-buffer'.
Note that the real values of candidates are copied and not the
display values."
  (interactive)
  (with-helm-alive-p
    (helm-run-after-exit
     (lambda (cands)
       (with-helm-current-buffer
         (if (region-active-p) (delete-region (region-beginning) (region-end)))  ; added to delete region if any.
         (insert (mapconcat (lambda (c)
                              (format "%s" c))
                            cands "\n"))))
     (helm-marked-candidates))))

Is there any better way to fix it?

In general, how to make sure insert comply with (delete-selection-mode t)?


texts:
I'm trying to get pcase to match against a let-bound variable. However, I can't seem to get pcase to recognize the variable correctly.

See this minimal example:

(let ((a 1)) (pcase 2 (a 7)))  => 7    ;; as predicted by the docs
(let ((a 2)) (pcase 2 (`a 7))) => nil  ;; ???

How can I get pcase to return 7 iff a = 2?

(An alternative to pcase with similar features would also suffice.)


texts: org odt export: how to create a two columns section

texts:
In libreoffice I can insert a two column section. In org mode,
creating a two_columns page style and use

#+ATTR_ODT: :style "two_columns"

can produce a two column document, but org mode doesn't seem to have a section break like

# +SECTIONBREAK:

How can I switch from a two columns section to one column section?


texts: disable search in home folder with projectile

texts:
Sometimes I use dired to navigate in the home folder. If in that moment I press projectile-find-file, emacs will freeze and will take about 15 seconds to be ready to use projectile with the home folder.
How can I tell projectile not to search in the home folder, even if I accidentally call projectile-find-file when I am in?


texts: How to display (mask) a certain character as another

texts:
I want to display every & character in my code as a λ instead. But I don't want the file to be changed. It must be just a "visual effect".

& Ampersand U+0026 Unicode
λ Greek Small Letter Lamda U+03BB Unicode

Like:

Enum.reduce([1, 2, 3], &+/2)

To be shown as:

Enum.reduce([1, 2, 3], λ+/2)

Is that possible? How?


texts: How to append header arguments to result code src block?

texts:
For example, I have an src code block which can generate another code block:

#+BEGIN_SRC sh :results code :wrap systemd
systemctl --user cat rslsync.service
#+END_SRC

#+RESULTS:
#+BEGIN_systemd
# /usr/lib/systemd/user/rslsync.service
[Unit]
Description=Resilio Sync service
After=network.target

[Service]
Type=simple
User=rslsync
Group=rslsync
ConditionPathExists=/run/media/stardiviner/Collections
ExecStart=/usr/bin/rslsync --nodaemon --config /etc/rslsync.conf
Restart=on-abort

[Install]
WantedBy=multi-user.target
#+END_systemd

I wish to append header argument :tangle "/sudo::/usr/lib/systemd/user/rslsync.service" to
upper result code block.


texts: How to make org prompt for a timestamp, when changing state of a TODO?

texts:
I have so many tasks I do far away from my computer with emacs. Now, when I change state of a TODO, it just logs the current time into the drawer. But the difference with actual time of the event may be many hours, if not days.

Is there a way to make it prompt for a timestamp I'd like it to log?


texts:
I am using web-mode for my php files: http://web-mode.org/

And I call often a php function which looks like this:

__lg('Some text here', 'Global', NULL, FALSE);

This function can be call with only one argument like:

__lg('Hello world');

Is it possible to automaticly highlight the text between the 2 single quotes of the first argument of my function __lg() ?

I would like it to be colored in #ff007c for exemple.

I think I would have to modify the library web-mode.el that I use ?


texts: Make a variable visible to some functions only

texts:
Consider the following metacode:

;;; -*- lexical-binding: t -*-

(defvar var1 ...)
(defvar var2 ...)

(defun main ()
  "Main entry point" ...)
(defun func1 ...)
(defun func2 ...)
...
(defun funcn ...)

(defun f ...)
(defun g ...)

If a variable is relevant to the whole logic of your program, you make it visible to all functions declaring it global in defvar. If a variable is relevant only to some functions, say f and g above, you make it visible to the latter functions only. This is known as friendship, avoids "cluttering" the global space and can be easily implemented in elisp like follows:

;;; -*- lexical-binding: t -*-

(defun main ()
  "Main entry point"
  (message "f: %s; g: %s" (f) (g)))

(let ((x 0))
  (defun f () (1+ x))
  (defun g () (+ 2  x)))

Now f and g share the same variable x without using the global space, that is  without (defvar x 0).

Unfortunately the compiler wrongly complains:

Warning: the following functions are not known to be defined: f, g

One can use without problems the byte-compiled code, but in so far as you want to use the compiler to lint your code,  false positives are not welcomed. Plus, the let-bound variable x becomes static.

I would like to find an alternative approach avoiding warnings and static variables.

What I am not looking for

I am aware of this question. Will Kunkel receives the same warning, however   he has a totally different objective: he "want(s) to get the effect of a static variable by using defun inside of let".

I have not one but several defuns and want to share variables, not make them static.

IMHO the proposed let-bound variables in defalias are better avoided because calling twice the defalias function may cause an error difficult to spot as it does not stop your program, it just produces a biased output. Of course, this does not apply in specific cases when  you explicitly need your function to keep its value between invocations.


texts: How can I prevent/override key translation behavior such as: µ (translated from A-m) runs the command self-insert-command

texts:
I've bound a command to A-m, however some package that I load seems to modify input translation maps (input-decode-map, local-function-key-map, function-key-map, key-translation-map) that interfere with my intended behavior for the key, which is to run the command I've bound it to. Instead when I press A-m I get:

µ (translated from A-m) runs the command self-insert-command

My questions here are:

How can I override this behavior if a package interferes like this?
How can I quickly zero-in on which package has interfered in this way without the slow and painful comment-packages/restart emacs cycle?
Prevent packages from overriding my custom settings-- or at least warn me when modifying the input maps so I can easily figure out which package without hunting?


texts: Problem about `evil-visual-state` and advising `read-key-sequence` with `call-process`

texts:
In Evil mode, after I enter visual-state, I can use f to expand the selection by jumping to a character. Now if I've pressed f after entering visual-state, Emacs asks me to input a character to jump to, which I think is implemented using read-key-sequence. What I want to do is to call some external process before I enter the character, so I advise the read-key-sequence function(below is a simplified version):

(defun foo (orig-func &rest args)
  (with-temp-buffer
    (call-process "ls" nil t))
  (apply orig-func args))

(advice-add 'read-key-sequence :around 'foo)

Now I enter the visual-state, press f, enter the character, jump to it, and nothing is shown selected, i.e., the region is not active.

However, if I just change the parameter of call-process by setting the fourth argument(destination) to be nil, i.e., using the following version of foo:

(defun foo (orig-func &rest args)
  (with-temp-buffer
    (call-process "ls"))
  (apply orig-func args))

Everything works fine, exactly like without adding advice to read-key-sequence.

My question is, is there something I did wrong, or something of call-process and Evil implementation will magically change the state of the region?


texts: spacemacs combine yas-snippet + autocomplete

texts:
I am pretty new to spacemacs and I am still trying to configure it to my needs.
In emacs I use yas-snippet a lot and I am fond of the autocomplete feature in spacemacs.

Apparently there is a way to combine the two via company-mode that I found on github, but I have no idea where I have to place the configurations.

I hope someone can help me. I would like to avoid setting a new key for company-yasnippet because the integration with the autocomplete drop menu would greatly speed up the working process.


texts: How can I make Spacemacs stop deleting my parentheses?

texts:
I've recently switched from emacs to spacemacs (develop branch), and I'm still getting used to the new defaults. I added smartparens to my excluded-packages in my config file, because I don't like parenthesis matching. Ususally, I open and close parentheses myself, and then C-b to move between the parens and type. But once I turned off smartparens, if I move between parens that I opened and closed, it will sometimes delete the close paren that I typed. In particular, this happens when I am in a function or for loop, or something else with a close curly brace. I'll type someFunctionCall() within a for{}, and as I'm filling in the arguments to the function call, the ) will disappear and the } will turn red, like it's upset that I'm trying to close the ( with the wrong bracket type. How do I stop this behavior? I've attached my .spacemacs as a gist for reference. I've seen this happen in ESS and C-mode so I don't think it's mode specific.

https://gist.github.com/esander91/d9fad132988965b6d015


texts:
Could someone in the know please help me understand what's going on here:

;; -*- lexical-binding: t; -*-
(let* ((a 0))
  (let* ((a 1))
    (funcall (byte-compile (lambda () a)))))
;;=> 0

wat? Not only that, but with lexical-binding off this actually returns 1. I even Edebug stepped the byte-compile and it definitely sees closure with a correctly shadowed and holding 1. Do I misunderstand scoping rules here or how byte-compile works?

PS: or is that an artifact of eval-last-sexp somehow? Because I just tried this and it worked as I expected:

(lexical-let* ((a 0))
  (lexical-let* ((a 1))
    (funcall (byte-compile (lambda () a)))))

EDIT Yet another unexpected quirk that maybe related.

Let's define a function that checks if lexical-binding is enabled. Then define a macro that inserts that check before doing whatever.

;; -*- lexical-binding: t; -*-

(defun test-for-lexical-binding ()
  (unless lexical-binding
    (error "lexical binding disabled!")))

(defmacro foo-macro ()
  `(progn
     (test-for-lexical-binding)
     42))

Let's now use that macro in foo.el.

;; -*- lexical-binding: t; -*-

(foo-macro)

You can byte-compile-file fine, but the moment you load the byte-code the check fails:

(byte-compile-file "foo.el" 'load)
;;=> lexical binding disabled!

You can easily verify with (eval-when-compile lexical-binding) that lexical-binding is indeed set when you compile, but nil when the code actually runs.


texts: Flycheck + shellcheck: always use new temporary frame, not modeline

texts:
I have been using both flycheck and shellcheck for just under a week under emacs 24.5.1.  They work fine in principle.

I have a question though regarding flycheck's choice to simply use the modeline vs. using a new temporary subframe (in the current frame, at the bottom, in my case) to display its warnings/errors.

It occurs to me (cross checking with cli shellcheck output on the same source file) that flycheck is creating the above mentioned ephemeral frame for multi-line warnings/errors that occur on the same column, while using the modeline for all other warnings/errors.

I would like to configure it to always use an ephemeral frame, but can't seem to find out how. Anyone can help out?


texts: How to update window-start without calling redisplay?

texts:
While debugging swiper I've encountered a situation when
the point is changed inside with-selected-window, but window-start isn't updated.

This can be annoying, because I need the up-to-date window bounds to update the overlays.
From the doc, I've read that window-start can be updated with redisplay, and it is indeed updated,
but calling redisplay after each key results in uncomfortable screen blinking and tearing.

Is there a way around it, i.e. update window-start like redisplay does it, but don't actually
redisplay to avoid blinking?


texts:
I'm using toggle-scroll-bar to show scrollbar on my frame. But is there a way to show scrollbar only on the selected buffer?

I think I can use focus-in-hook to detect when a buffer is active, but I don't know how to show scrollbar on it.


texts: Can org-babel results be output as code comments?

texts:
In blogs, textbooks, etc, it's really common to display the results of some code as comments, e.g.:

(+ 1 1) ;=> 2

Is there a way to display results like this automatically using Org-Mode's Babel feature?

Specifically, what I'd like is to be able to specify a header such that this:

#+begin_src scheme <some headers>
(+ 1 1)
(/ 4 (* 2 2))
#+end_src

Would turn into the following when I C-c C-c:

#+begin_src scheme <some headers>
(+ 1 1) ;=> 2
(/ 4 (* 2 2)) ;=> 1
#+end_src

And then if I made some changes, like so...

#+begin_src scheme <some headers>
(+ 1 5) ;=> 2
(/ 8 (* 2 2)) ;=> 1
#+end_src

...and C-c C-c, it would replace the comments with updated ones:

#+begin_src scheme <some headers>
(+ 1 5) ;=> 6
(/ 8 (* 2 2)) ;=> 2
#+end_src

Or, short of what I've dreamed up above, is there an easy way to have results displayed by github's org file renderer, so the following would be visible (ideally with formatting that I specify at the document level):

#+RESULTS:
: 2


texts: Is the single quote interpreted as repeating the character that follows the single quote?

texts:
When I copy some text with single quote and paste (by right clicking and choosing paste) into a emacs buffer with fundamental mode, the single quote seems interpreted as repeating the character that follows the single quote.

For example:

what's

is interpreted as

whatsssssssssssssssssssssssssssssssssssssss

Why does this happen?  Should I paste into a buffer with a different mode?

I am running emacs in cmd terminal of Windows 10 by emacs -nw.

If I run emacs in GUI by emacs -Q, then the problem doesn't happen.


texts:
For educational purposes I wish to replay the characters that I enter in the buffer at some slow typing speed. Selecting the regions I could do this in would also be great.
Is there any emacs package that provides such a feature?


texts: How to set default encoding to utf-8, and default line ending to linux style?

texts:
I use this piece of code to set the default line ending to linux-style \n

;; https://www.emacswiki.org/emacs/EndOfLineTips

(add-hook 'find-file-hook 'find-file-check-line-endings)

(defun dos-file-endings-p ()
  (string-match "dos" (symbol-name buffer-file-coding-system)))

(defun find-file-check-line-endings ()
  (when (dos-file-endings-p)
    (set-buffer-file-coding-system 'undecided-unix)
    (set-buffer-modified-p nil)))

And this - to set the default encoding to utf-8

;; emacs set default codepage

;; https://stackoverflow.com/questions/1785200/change-emacs-default-coding-system

(prefer-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)

But it looks like because of the second one, first isn't working. Now line ending is \r\n on saving, even if I manually change it.


texts: How to query/set the character encoding?

texts:
How can I find out what character encoding Emacs employs in saving a text file to disk? And how can I specify this encoding?

Operating system: macOS Sierra, Version 10.12.5
Emacs: GNU Emacs 25.1.1


texts: How to subtract time values formatted as "HH:mm"?

texts:
I want to subtract time values like 12:04 from 11:30 and get 34 minutes or 0:34.
I tried to achieve this using calculations like
(time-subtract
 (parse-time-string "12:04")
 (parse-time-string "11:30"))

This way I get the error Invalid time specification.
OK. Maybe I need to encode times first:
(time-subtract
 (apply #'encode-time (parse-time-string "12:04"))
 (apply #'encode-time (parse-time-string "11:30")))

Now I get the error Wrong type argument: fixnump, nil.
Is there a way to subtract times without having to calculate total minutes of both times first like 12 * 60 + 4?


texts: Bizarre behaviour using `call-process': cabal fails as if it is in wrong directory, but succeeds with 'cd ./ ; cabal'

texts:
I'm trying to get haskell-mode working on Windows but something funny is happening and I've traced my problems using Edebug into the bowels of emacs:
Can someone explain the following strange behaviour of call-process* to me:
Setup:
;; Set Variables (same behaviour with cygwin and other shells)
(setq shell-file-name "C:\\Program Files\\Git\\bin\\bash.exe")
(setq shell-command-switch "-c" )
(setq out-buffer (get-buffer "out"))

then:
(call-process shell-file-name nil out-buffer nil shell-command-switch "cabal build")
This fails with cabal complaining about being in the wrong directory

cabal.exe: No targets given and there is no package in the current directory...

However, adding pwd:
(call-process shell-file-name  nil out-buffer nil shell-command-switch "pwd ; cabal build")
shows that bash is in the project directory (i.e. the current buffer's default-directory):

/f/path/to/my-project
cabal.exe: No targets given and there is no package in the current directory...

Then bizarrely:
(call-process shell-file-name  nil out-buffer nil shell-command-switch "cd ./ ; cabal build")
Somehow works and cabal is happy and builds my Haskell project??

Set up: Windows 10, GHC 8.10.2, Cabal 3.2.0.0, emacs 27.1, haskell-mode 20201120.755
* Function: call-process program &optional infile destination display &rest args
doc: https://www.gnu.org/software/emacs/manual/html_node/elisp/Synchronous-Processes.html
( See my previous mess of a stack overflow question for the full output of cabal error but I'm fairly sure this isn't a Haskell/cabal problem, something funny is going on with emacs:
https://stackoverflow.com/questions/65606600/emacs-haskell-mode-with-cabal-project-unrecognised-target-syntax-for-ghc-o )


texts: When `emacs` is started, use `emacsclient` instead if there is a server

texts:
Most modern editors don't have a separate <editor>client binary. Instead, the main binary acts as a client to open a new window/the file given as an argument when possible.

Is there a way to accomplish the same in Emacs? I know about emacsclient but 1. it's not a drop-in replacement and 2. using it comfortably requires additional setup beyond copying .emacs.d to a machine -- e.g. adding a desktop file for emacsclient.

I'm envisioning something like this:

;; Start of init.el
(if (server-running-p)
    ;; Open given file in existing server
  (server-start))


texts: How to tell Ivy to use completing-read-default for specific command? (org-tags-view, in particular)

texts:
Ivy (+swiper +counsel) is very cool and I use it constantly for an ever growing number of tasks. But there are some cases in which the requirements of a certain completion task defeats Ivy's logic. One of those is Org tags search, more precisely, org-tags-view which is commonly bound to C-c a m. And this command conflicts with Ivy's logic both because it requires (typically) multiple candidates, and is supposed to output a single string out of them, connected by plus or minus signs. So a typical case would be "+tag1+tag2-tag3".

The default completion works better in this case, and while using Ivy, I'd like to tell it to use default completion in this particular function. Theoretically, there is already a defcustom meant for this task: ivy-completing-read-handlers-alist. But I cannot get it to work with org-tags-view.

I've tried:

(add-to-list 'ivy-completing-read-handlers-alist
             '(org-tags-view . completing-read-default))

But also, as org-tags-view calls org-make-tags-matcher internally:

(add-to-list 'ivy-completing-read-handlers-alist
             '(org-make-tags-matcher . completing-read-default))

Neither inhibited Ivy completion from kicking in. Does anyone know what I may be missing? Or how to get this to work?


texts: How do I force a specific buffer to open in a new window?

texts:
When committing changes in Magit, it is useful to have the diff view open while adding details about the commit.

In Magit, we see the diff in the *magit ..* buffer. When you hit cc while the cursor is on a Staged file, the Magit commit buffer .. COMMIT_EDITMSG pops up. By default, this new buffer replaces the *magit ..* buffer that was showing the commit diffs.

QUESTION -
How do I make the .. COMMIT_EDITMSG buffer open in a new window (reuse a different window or create a new window if the frame had just 1 window to begin with) so that I can see both the *magit ..* and .. COMMIT_EDITMSG buffers?


texts:
M-w stops working randomly on my Windows 10, which I believe is the same issue described here. Unfortunately no solutions can be found.

To sum up:

M is mapped to Alt
The problem occurs to ALL Emacs installations, i.e. as a native Windows app, an app in the WSL subsystem, and native linux app in a Putty session.
The problem occurs randomly, but once it appears, the only solution is a system reboot.
Other shortcuts like M-x or ESC-w work

Any ideas?


texts: Is XEmacs source code repository indeed lost?

texts:
Even though BitBucket service warned everyone quite in advance that it would stop hosting Mercurial repositories, it seems that in many months no-one bothered to convert XEmacs repository to Git.
The instructions at xemacs.org are but obsolete now:

http://www.xemacs.org/Develop/hgaccess.html

The list of repositories is now empty:

https://bitbucket.org/xemacs/

More, the old CVS repository (see http://xemacs.sourceforge.net/Develop/cvsaccess.html) is unavailable, either, since alioth.debian.org was shut down more than two years ago.
Update: there's also a recent topic on Reddit: Archive of Bitbucket.org Mercurial repositories.


texts: Sum to end of row in Org Mode Spreadsheet

texts:
I've tried both of the following formulas:

=vsum($4..$>)
=vsum(@0$4..@0$>)

It seems like either of these should work.


texts: When doing a yank after an isearch-forward/backward, the most natural thing that one wishes to happen is to isearch the string provided by that yank. How to realize this?


texts: Is there a way to set arbitrary characters as the word boundary?

texts:
I know I can do this kind of thing with the sentence boundary, using (setq sentence-end "[regexp]"), but how can I do this with the word boundary?

I'd like to add capital letters to the default word boundary symbol sets, so that I could use forward word command from the beginning of the line below to select only the "set".

setWordBoundary blah blah blah


texts: Is it possible to bind CTRL-SHIFT-xxx and CTRL-num combination?

texts:
I'm very new to emacs and essentially came from vim where it is not possible to bind CTRL-num combination like (CTRL-1, CTRL-2, etc) which as well as CTRL-SHIFT-xxx like CTRL-# which essentially works as simply #.

Is something like this possible in emacs?


texts:
What controls the print depth of lisp forms? For example:

(macroexpand '(defun foo () (let ((bar)) (+ 1 2))))

becomes

(defalias (quote foo) (function (lambda nil (let ... ...))))

in the *Messages* buffer.


texts: How to interpret the org-mode-map key binding?

texts:
From the docs https://org-roam.readthedocs.io/en/master/ecosystem/, org-mode-map has binding for s-Y
(use-package org-download
  :after org
  :bind
  (:map org-mode-map
        (("s-Y" . org-download-screenshot)
         ("s-y" . org-download-yank))))

What does s-Y mean ? org-mode-map displays a number.
(keymap
 (8388729 . org-download-yank)
 (...)

To which key is org-download-yank bound?


texts:
I am currently trying to install spacemacs on my Arch Linux. I am following the standard installation instructions that have been put up here.

Now after cloning the .emacs.d from the spacemacs repository, whenever I open emacs, I get the error:

File error: Creating directory, Permission denied, /home/sharand/.emacs.d/. cache

After which, the suggestion on this question prompted me to create a .cache folder inside .emacs.d. But after this, I reopened emacs to get this error:

File error: Creating directory, Permission denied, /home/sharand/.emacs.d/.cache/auto-save

Now I am stuck in a cycle of creating folders and reopening emacs. I just want to know how to change the writing permissions of emacs. Invoking a sudo emacs, just makes it go to the default emacs and does not bring up spacemacs (does anyone know why this is the case?).

How would I go about making sure that I have writing permissions for emacs?


texts: How to store the variable value after Emacs was closed

texts:
Suppose, we have a variable defined in ~/.emacs:

(defvar *my-var* "")

Then in **scratch** buffer we set some value to it:

(setq *my-var* "value")

After we close emacs the value will be lost. How can we store the value to disk and read it again when Emacs is started?


texts: What does =slug= means in the context of =org-roam=?

texts:
I'm trying of configuring org-roam-bibtex (not there yet), but I keep finding this ${slug} function, which I don't understand. See for example This post.
What is it? What is its utility?


texts: How to enable Ctrl-Option combinations with OS X

texts:
I can't get simultaneous presses of Ctrl + Option and other keys to register in Emacs. For example, if I press Ctrl-h c (describe-key-briefly) and then Ctrl-Opt-f, it doesn't recognize that I've pressed any keys.

Ctrl key combinations (like C-f) work, Meta key combinations (like M-f) work, and Escape + Ctrl sequences work ( C-F translates to C-M-f). The behavior is the same if Emacs is run

I'm using Emacs 26.1, installed via Homebrew.


texts: bibtex customize sort-field in bibtex-entry-format

texts:
I am trying to customize the behavior of M-x bibtex-entry-format function to reformat a bibtex entry in a bib file.

I want that the various fields in an entry are sorted to a given ordering. In my emacs init file I put this:

(setq bibtex-entry-format
      `(page-dashes required-fields
         numerical-fields whitespace last-comma delimiters
         unify-case sort-fields))

so it applies sort-fields to its default behavior, however, I want to customize it. How can I set my sort-field own criteria?


texts: er/expand-region not working as previously under Emacs 25.1

texts:
I've got er/expand-region behaving very strangely and I don't understand what I did wrong (besides upgrading to Emacs 25.1.50).

If I've got this in an elisp file:

(defun foo (p) (* 2 2) p)

(that piece of code is just an example)

and I'm on the asterisk and start doing expand-region I get:

"*"(OK)
"* 2 2" (OK)
"* 2 2)" (WRONG)
"(* 2 2)" (kinda OK I guess)
"(* 2 2) p)" (WRONG)
"(defun foo (p) (* 2 2) p)" (kinda OK I guess)

I've got the exact same problem with Clojure files.

Previously er/expand-region used to select things in between matching parenthesis. The problem is that now I need more keypresses to select what I want and I keep ending up with unbalanced elisp / Clojure code because I cut/kill non-balanced pieces of code.

I tried both calling er/expand-region using the shortcut or calling it manually: same result. From my testing it looks like, say, when in Clojure the clojure-mode-expansion list is used etc.

I'm not familiar at all with how er/expand-region works internally but it's as if something was called before er/mark-inside-pairs and er/mark-outside-pairs and that that thing was matching the right parenthesis.

Any idea as to what went wrong and how I could fix this?

I tried both my old er/expand-region and the latest ELPA one.


texts:
I'm interested in trying to track where my ideas come from.

Suppose I open files f1,f2,f3
and cut-and-paste lines from these files into f4.

I'd like to record this information in a log file (say f4.meta)

(at  copied data from f1 to f4)

Is there a way to do program this?

Also if I copy and paste text from outside emacs (say a browser)
is there some way to track and time stamp where the data came from?


texts: How to make emacs running in daemon mode read my bashrc before start?

texts:
I run Emacs in the daemon mode as a user's systemd unit. However it won't read my environment variables. How to make it import my .bashrc first?
I have multiple paths added in there and want to be able to use them in Emacs (but I don't want to maintain both .bashrc and .emacs by adding them to exec-path).


texts: Separating Customize settings from other Init-file settings

texts:
Currently all my settings that come from the customize interface are placed in:

(custom-set-variables

  '(menu-bar-mode nil)
  '(ivy-mode t)
  '(blink-cursor-mode nil)
  '(hl-line-mode nil)
  '(inhibit-startup-buffer-menu t)
  '(inhibit-startup-screen t)
  '(initial-scratch-message nil)
  '(scroll-bar-mode nil)
  '(show-paren-mode t)
  '(tool-bar-mode nil)
)

However, these settings eventually get buried inside the auto generated code that accumulates over time.

I would like to move some of these settings outside of the customize-interface into their own dedicated section so that I can keep track of them easily.

From what I understand I can't create a second custom-set-variables section because that's reserved for the auto generated code.

I don't know elisp well enough to know how to do this effectively.

Some guides suggest placing this anywhere in the init file:

(menu-bar-mode -1)

I've also seen this version:

(menu-bar-mode 0)

But this doesn't seem to work for all settings and some of them just give errors at startup. like this one for example:

(ivy-mode 1)

Results in:

Symbol's function definition is void: ivy-mode

So what is the right way to organize settings outside of the customize-interface?

And how do these formats differ? -1 0 1 t nil etc.

** Answer in comments.


texts:
This is a weird problem, and I can't see to find an answer anywhere. I have a file with 5 images that I want to show inline. I'm sure this worked for me yesterday, but today I can not make it work.

If I toggle inline mode, C-c C-x C-v, I get the message 2 images displayed inline. However, I can click the three other links, and the images open in new buffers. I can also export the document to PDF using LaTeX, and the images show.

Any help is greatly appreciated!


texts: prevent auto indent temporarily for multi line conditional, loops, etc

texts:
When I am writing in c-mode, I prefer to write multi-line control statements in the following way.

if( cond1
 && cond2
 || cond3
) {
    /* stuff */
}

for( i = 0;
     i < N;
     ++i
) {
    /* stuff */
}

while( cond1
    && cond2
    || cond3
) {
    /* stuff */
}

However, emacs does not make this easy.

Adding a new condition line re-indents the ) { immediately following
the conditions.
Within the ( ) of these control statements the && and ||
automatically re-indent whenever parenthesis are entered.
Each newline within the control structure's () indents to the normal
indent.

What can I do to make writing these easier?

P.S. Creating a yasnippet template does not work. The ) { automatically indents on completion.


texts:
I hover over stdlib:
#include <stdlib.h>

I type M-. and it asks me:
Visit tags table (default TAGS):

I don't have one of those.  I see a lot of information about TAGS in the emacs documentation:
https://www.emacswiki.org/emacs/TagsFile#tags_file
But what should I use, CTAGS, ETAGS, Universal CTags, Global Tags?  Should I set this up in the makefile or in a key binding?


texts: Export an org-mode file as a PDF via command line?

texts:
What command-line arguments do I use to get Emacs to export an org-mode file to a Beamer PDF?  (I want to create a Makefile that produces a PDF when the user runs make.)

I tried following this answer but couldn't get it to work:

$ emacs --batch foo.org -f org-beamer-export-to-pdf
Symbol's function definition is void: org-beamer-export-to-pdf
$ emacs --batch -l ox-beamer foo.org -f org-beamer-export-to-pdf
Cannot open load file: ox-beamer

The above error comes from the fact that the org-mode files are in a custom location and my ~/.emacs.d/init.el is not loaded (--batch implies -q a.k.a. --no-init-file).

If I tell Emacs to load my init file it will work:

$ emacs --batch -l ~/.emacs.d/init.el foo.org -f org-beamer-export-to-pdf

However, this doesn't work for other users that use ~/.emacs or ~/.emacs.el instead of ~/.emacs.d/init.el.  I tried telling Emacs to load user-init-file but it didn't work:

$ emacs --batch --eval '(load user-init-file)' foo.org -f org-beamer-export-to-pdf
Wrong type argument: stringp, nil

Assuming all users can successfully press C-x C-e l P to export a Beamer PDF when using Emacs interactively, what non-interactive command will produce a PDF?


texts: Scheduling/Refiling Trouble with org-gcal / org-agenda

texts:
I'm using org-gcal with org-agenda.

Because org-gcal seems to strip entries of any TODO markers, I would like to create entries in my org-gcal synced file by using refile to copy over entries from my to-do list file.

However, when I refile an entry with a SCHEDULED: time-stamp into my org-gcal synced file, I get two time stamps in the resulting entry.

For example I start with an entry in my to-do list file that looks like

* Demo trouble with refile
  SCHEDULED: <2017-07-15 Sat>

Then I refile it to my org-gcal sync file, I get

* Demo trouble with refile
  :PROPERTIES:
  :LINK: [[https://www.google.com/calendar/event?HIDDEN][Go to gcal web page]]
  :ID: vrvehri7aa1lktb6u1aee15roc
  :END:

  <2017-07-15 Sat>

  SCHEDULED: <2017-07-15 Sat>

And the two time stamps cause the entry to show up twice in my agenda view.

However, if I start without an entry with a time stamp that has no SCHEDULED: prefix, then things work better.
For example, if I start with

* Demo no trouble with refile
  <2017-07-15 Sat>

Then after refiling to my org-gcal synced file I get

* Demo no trouble with refile
  :PROPERTIES:
  :LINK: [[https://www.google.com/calendar/event?HIDDEN][Go to gcal web page]]
  :ID: 4irlnqb3g1u6nv29gq9tiockbk
  :END:

  <2017-07-15 Sat>

I can imagine at least two ways of fixing my issue. One would be if I could stop the "C-c C-s" scheduling command from adding the SCHEDULED: prefix before the time stamp.
Another solution would be if I could make the refile command automatically reformat the entry before inserting it into the org-gcal synced file.

Currently, to get around the problem I'm adding time stamps by going to the agenda file and using "C-c ." to get around the problem, but this is very unsatisfactory.


texts: Open a file in read-only preprocessed mode

texts:
I often create files with a special extension, e.g. pkl (python pickle), and would like to display these in a read-only buffer after processing them with some external command.

E.g. in the case of pickle files I'd like to automatically run a python command (print(pickle.load(open(filename)))) on the file and display the command's standard output.

In a way it is similar to how opening a docx file triggers docview, and opening a png file, triggers image view.

Has someone written something like this?


texts: Is it possible to replicate vim-unimpaired [p paste behaviour?

texts:
Evil-unimpaired (https://github.com/zmaas/evil-unimpaired/) tries to replicate vim-unimpaired, but the paste behaviour is just a dumbed down version of the original.
The evil-unimpaired behaviour on [p:
(defun evil-unimpaired-paste-below ()
  (interactive)
  (evil-insert-newline-below)
  (evil-paste-after 1 evil-this-register))

It just inserts a newline and then pastes the register content. It doesn't care whether register content has a newline or not. It just inserts a new line anyway. Let's say I have the following text and I copy the second line with yy:
first line
   |second line

When I paste with [p it becomes
first line
    second line

   |second line

which is not a desirable output. Compare it to vim-unimpaired behaviour:
first line
   |second line

Paste with [p
first line
    second line
   |second line

The same problem applies to ]p which is supposed to paste text above current line. I want to know if there is a existing solution or can someone show me how to update the evil-unimpaired function so it works properly. My emacs-fu is pretty much nonexistent, unfortunately


texts:
How do I completely disable all auto-indentation in Emacs?  I need to disable it at least for Fundamental mode, but I'm fine with it being disabled globally for the current session.

Please read the rest of this question before declaring it a duplicate.  All the other answers I've found are for much more targeted disabling of indentation.  I really want to completely disable all auto-indentation for the whole session.

Setting electric-layout-mode to nil does not work.

Details

Sometimes I like to compose large Git commit messages with my Windows ASCII text editor.  These messages frequently have bullet lists, code blocks, or other things where the precise formatting in my source document is meaningful.  My codebase is on Linux, and I connect to the box using a text-only SSH client.  When Git enters Emacs for editing the commit message, I want to be able to copy the source commit message to the Windows clipboard then paste it using Windows paste commands.  From the perspective of Emacs, I'm typing what was found in the Windows text file.  Unfortunately, when Emacs sees indented lines, it adds its own auto-indentation, so I get this huge triangle of whitespace along the left edge of the buffer.

I'm using GNU Emacs 24.3.1.

Workaround

My current workaround is to transfer my Windows text file to a filesystem that's mounted by my Linux host, load the file into Emacs, then use kill and yank to transfer the content.  This is a bit clunky.

Example

Here's an example block of text:

a

  - b
    c
    d

Here is how it appears when I paste that into Emacs-under-ssh via MSWin paste:

a

  - b
      c
          d

If I press C-h l after doing the paste, here is what I see.  Note that the newlines are input using C-j, not RET.

a C-j C-j SPC SPC - SPC b C-j SPC SPC SPC SPC c C-j
SPC SPC SPC SPC d C-j C-h l


texts: Exporting an `org` file to a personal LaTeX class

texts:
I have a personal LaTeX class called MyThesis, and I want to be able of exporting from org to LaTeX.

Q: How can I call this class that is not in the main tree of texlive?

I have this in my .emacs

(use-package org
  :defer t
  :config
  (use-package ox-latex
    :defer 5
    :config
    (add-to-list 'org-latex-classes
         '("MyThesis"
           "\\documentclass{MyThesis}"
           ("\\part{%s}" . "\\part*{%s}")
           ("\\chapter{%s}" . "\\chapter*{%s}")
           ("\\section{%s}" . "\\section*{%s}")
           ("\\subsection{%s}" . "\\subsection*{%s}")
           ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
         )
    )
  )

but I don't know how to tell it where if the file! (Shame on me!)


texts: How to prevent #+BEGIN_LaTeX from generating \begin{LaTeX} when exporting to .tex source?

texts:
I am a beginner and have been using emacs for around a month. I'm still finding my way around. Sorry if this is a very basic question.

I'm trying to write a scientific document in org-mode and using org-ref for citations and references. I'm also using CDLaTeX mode for easier math input. To let org-ref find my equation labels, I have to enclose then in a #+BEGIN_LaTeX and #+END_LaTeX block. I have something like this

#+BEGIN_LaTeX
\begin{equation}
\label{eq:unitary-evo-state}
\ket{\psi(t)} = U(t) \ket{\psi(0)} \qq{and} \imath\hbar\ket*{\dot{\psi}} = H(t)\ket{\psi}
\end{equation}
#+END_LaTeX

When I export this to a LaTeX file, it generates the following LaTeX code

\begin{LaTeX}
\begin{equation}
\label{eq:unitary-evo-state}
\ket{\psi(t)} = U(t) \ket{\psi(0)} \qq{and} \imath\hbar\ket*{\dot{\psi}} = H(t)\ket{\psi}
\end{equation}
\end{LaTeX}

The outer \begin{LaTeX} and \end{LaTeX} tags essentially insert a \latex before the equation.

Is there a workaround for this? I was using John Kitchin's org-ref video as a reference and this behavior does not happen there.

I'm using Doom emacs with TeX-Live on Ubuntu. Any help is much appreciated. Thank you very much.


texts: Copy/paste between SSH terminal Emacs and macOS

texts:
Suppose you are working in macOS, and you decide to SSH into a Linux box and fire up terminal Emacs. How do you copy and paste between macOS and your SSH terminal-Emacs?

Copying and pasting between macOS and local terminal-Emacs is not a problem with xclip: install xclip through ELPA and put (xclip-mode 1) in your Emacs init file. This doesn't work when running terminal Emacs over an SSH session, however, and while there is much information online about accessing the X11 clipboard from Emacs, I am running terminal Emacs on a remote machine that doesn't have X11 installed either way. Is there a solution for terminal Emacs copy-paste over an SSH session?


texts: yasnippet, "Wrong number of arguments" when in X11 window

texts:
Using yasnippet, whenever I use the yas-expand function to expand a snippet, the result depends on whether the emacs session is in an X window or not.  If I am in an in-terminal session of emacs, then the snippet is correctly expanded.  If I am in an X window, on the other hand, I get an error message call-interactively: Wrong number of arguments: (2 . 2), 0.

Have others encountered this problem, and is there a solution to it?

I am using yasnippet, with the latest version 20170127.2128 installed from melpa, using emacs 24.4.1 installed from the emacs24 package on Debian 8 (Jessie).

Edit: With toggle-debug-on-error

Debugger entered--Lisp error: (wrong-number-of-arguments (2 . 2) 0)
  py-indent-region()
  call-interactively(py-indent-region nil nil)
  command-execute(py-indent-region)

It looks like I was entirely mistaken about which function was being run.  I have yas-expand bound to C-c <tab>, but something else in my configuration overwrote that binding.


texts:
trying to setup go auto completion (using spacemacs), facing an issue while installing company
In end of data:
company-tng.el:198:1:Warning: the function ‘eglot--snippet-expansion-fn’ is
not known to be defined.

In end of data:
company-yasnippet.el:177:1:Warning: the function ‘yas-minor-mode’ is not known
to be defined.

Please suggest a solution
Thanks


texts: How to execute a shell script inside of emacs?

texts:
I simply want to execute the whole file I am editing right now in a small shell buffer just like I can run my python script.
How can I do this?


texts: Daemon mode: Defer interactive prompts on startup?

texts:
(Note that, title to the contrary, this question is not the same as How to start in daemon mode and suppress interactive dialogs?, as that question was "answered" by the submitter eliminating what was causing a particular prompt to appear.)

I'd like to know if there is a general way to keep emacs --daemon from hanging forever waiting for an answer to a prompt displayed in a minibuffer that doesn't exist yet.

It's impossible to connect with an emacsclient to answer these prompts, because the server doesn't start until Emacs finishes the startup sequence. (This means, if you have ALTERNATE_EDITOR set to the empty string, which makes an emacsclient that can't find a server start a new daemon, you can end up with multiple Emacs daemons all stuck and waiting.) I have to killall emacs and fix the problem before continuing.

I can play whack-a-mole with each thing causing a prompt on startup when I identify it (by starting Emacs in non-daemon mode and seeing what it's asking), but it's not a solution because it can't stop the next daemon from hanging on startup for a new reason.

To give an example: a common reason it would hang was after a system reboot or Emacs crash, when the first post-reboot Emacs wanted to know whether it was okay to steal lockfiles from the defunct Emacs. I could fix that by creating advice to make that prompt always answer "yes" without interaction. But then, one of the files that was open at the previous session save was a TRAMP file requiring a sudo or SSH password, so the daemon's stuck waiting on a password prompt. So I fix that by manually editing the session file (with vi or emacs -q!) to remove the offending files—but that doesn't keep it from happening next time.

So, I can stop loading my session automatically on startup and change it to a command I must manually execute from my first emacsclient. But if it isn't loading my session in the background so it's ready by the time I'm ready to use it, the entire purpose of the daemon is lost!

So what I'd like is:

(Best) Some way to defer minibuffer prompts until I open an emacsclient, while still completing the rest of initialization.
(OK) Some way to make all minibuffer prompts I haven't already advised otherwise as described above just return no unless an emacsclient is running. I can live with my TRAMP buffers erroring out so long as it mostly works.

Is there any way to achieve either of these goals?


texts:
Can I create a list of resources (e.g. people) and assign them to tasks? At least partially, without partial assignment and all other whistles.

I want it to be somewhat like it is in MS Project.


texts: I have a large bash script and I need to rerun certain lines of code. Normally I would comment out any line I don't want to run and then execute the file on the shell. But that is rather cumbersome. I'd much rather select the lines I want to execute and do something like M-x execute-selected-lines-in-the-current-directory. Is there something like that?


texts:
I am used to writing files where paragraphs are split into several lines, e.g. with fill-column. When I search for a string (C-s) such as this is a long text, the search results would not return the locations where the string appears with a line break between two of the words (like this\nis a long text).

Is there a command that would also return these results?


texts: How to fix incorrect emacs C#-mode indentation for method braces

texts:
My problem is that Emacs incorrectly indents the braces for C# methods, like this:

static string LOL()
    {

    }

then I have to manually correct it to

static string LOL()
{

}

I have read similar questions where the indentation is incorrect for if-statements and co. In my case the indentation works correctly. In spirit of those answers I have added these entries to my init.el

(defun my/c-mode-common-hook ()
  "Correct the expression indentation for c-style methods"
  (setq c-basic-offset 4)
  (c-set-offset 'substatement-open 0))

(use-package csharp-mode
  :mode "\\.cs\\'"
  :ensure t
  :defer t
  :init
  (use-package omnisharp)
  (add-hook 'c-mode-common-hook #'my/c-mode-common-hook)
  :config
  (add-hook 'csharp-mode-hook 'omnisharp-mode)
  (add-hook 'after-init-hook 'global-company-mode)
  (company-omnisharp t))

How can I make Emacs use correct indentation for these braces?


texts:
I wish to write full latex code then show result as a image in org mode. My idea is:

Use EXAMPLE block to write full latex code.
Use emacs-lisp to compile the latex code to png.
Show png file but "file:latex.png".

Code as below:

#+NAME: latexcircle
#+BEGIN_EXAMPLE
\documentclass[convert={outfile=latex.png},border=2pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[red] (0,0) circle (1cm);
\end{tikzpicture}
\end{document}
#+END_EXAMPLE

#+BEGIN_SRC emacs-lisp :var latexcode=latexcircle
(setq latexfile "tmp.tex")
(write-region latexcode nil latexfile)
(setq latexcmd (format "pdflatex --shell-escape %s" latexfile))
(shell-command-to-string latexcmd)
"file:latex.png"
#+END_SRC

#+RESULTS:
: file:latex.png

The file latex.png is created successfully but the result doesn't show the image.
I try to use "file latex.png but it doesn't work.


texts: How can I switch whitespace-mode enabled/disabled by key?

texts:
(defun switch-whitespace-mode ()
  (interactive)
  (whitespace-mode)
)

(global-set-key (kbd "<f6>") 'switch-whitespace-mode)

Through the above configuration，I failed.


texts: AUCTeX View PDF Evince SyncTeX subdirectory

texts:
I use LatexMK to output resulting files (including the .pdf and .synctex.gz) in the subdiretory out. But I also want to view the pdf and use SyncTex via Emacs and Evince.

One solution (see here) would require copying the .pdf and .synctex.gz after each compilation, but this is hacky. The comment afterwards (here) recommends editing the TeX-view-program-list-builtin. This seems like a good approach, but sadly, evince uses a built in function named TeX-evince-sync-view, and I dont know how to modify the input of this.


texts: I have specified two source Org files for Org-mode to search when creating an agenda. In the agenda view, how do I filter (view) tasks from only one of the files?


texts: Command to automatically define a resource variable in an Android project

texts:
When coding Android projects, resource variables are somewhat
cumbersome to define, as they involve visiting a file far away in the
directory structure and writing xml(!).

Say I want to define a string resource called street. I'll need to:

Visit res/values/strings.xml;
Type an xml entry like <string name="street">VALUE</string>.

If the resource was a number or a list, it goes into another file.

Ideally, this could all be done automatically.

I would write R.string.street in java code (which already have to do anyway);
Then I would just call this magic command;

The command could ask me for the VALUE to use, and it could infer
everything else from the R.string.street under point.

Is there a minor-mode or a command that will do this for me?


texts: avoid emacs to lock down or crash when used for many tasks

texts:
I consider to start using emacs for IRC, SQL, Shell and maybe twitter and Feed reading. But than I wonder how power users of emacs deal with emacs being single threaded.

So if I have one long-running task, like updating melpa packages, I can not switch to IRC, because emacs is blocked, isn't it?

And by the way: Emacs is one global beast. In programming I try to encapsulate functionality and shield one component from unintentionally breaking the other.

Emacs is configured as one piece and I already experienced how one minor mode interacts terribly with another one.

Or is it best practice to have different emacs processes and configurations for different tasks like IRC, email, etc?


texts: What's the idiomatic (or best) way to trim surrounding whitespace from a string?

texts:
I'm working with strings which may have any number of prefix and suffix spaces, tabs, newlines, etc.  Currently I have this:

(replace-regexp-in-string
 "^[^[:alnum:]]*\\(.*\\)[^[:alnum:]]*$"
 "\\1" my-string)


texts: re-search-forward through visible text only

texts:
I have one big org file. Sometimes I only want to search for a regular expression through the visible text, not the text that is folded; otherwise my search will take much longer.

How can I search for a regex match in only visible portion of a buffer?

I thought if a macro like with-visible-text existed it would be ideal. So something like (with-visible-text (re-search-forward "some regexp" nil t)) would search through only visible text.

I have tried to get hints on how to do this with forward-visible-line.
And I've seen I things like look promising like (next-single-property-change (point) 'invisible) which gives the the position of the next point that's not invisible. So I'm thinking maybe the solution to this is using re-search-forward with a boundaries which contain only visible regions.


texts: '(auto-revert-tail-mode t t) - duplicate content of buffer in git folder

texts:
Linux Mint 20
Emacs 27.2
In my init.el I has:
'(auto-revert-tail-mode t t)

And as result when I open file that in git repository (in folder with .git folder) then content of file is duplicate.
When remove this settings:
'(auto-revert-tail-mode t t)

then problem (duplication) is gone.
Here  more details info:
Duplicate headllines in org mode in CentOS


texts:
Why are some global minor modes applicable before package initialize while some are not? e.g. In init file global-linum-mode works but  projectile-global-mode doesn't. Why?

Also, why is there no global-helm-mode?


texts: Cannot remap key in evil-normal-state-map

texts:
I'm trying

(define-key evil-normal-state-map (kbd "o") nil)
(define-key evil-normal-state-map (kbd "o") 'evil-end-of-line)

but the key remains bound to evil-open-below.

FWIW I'm using spacemacs on emacs 24.5.1


texts: Fix org-mode agenda viewing of stuck projects with UK keyboard #

texts:
So this is a bit specialised. I've used org-mode for a while now but never before the agenda command to list a "stuck project".  The sequence built in to do this with org-agenda is C-c a #.  This doesn't work out of the box for anyone with a UK keyboard because the # key is on Alt-3 and Alt is bound to Meta (I can't realistically change this) in Emacs.  Actually I use Aquamacs but I don't think this is relevant.

I tried the method suggested in https://stackoverflow.com/a/4786456/1972730 namely

;; Allow hash to be entered
(global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#")))

and that does indeed allow me to enter # symbols in many contexts but when I enter the # symbol in the org-agenda context I get the error:

org-agenda-get-restriction-and-command: Wrong type argument: characterp, 134217779

So I could always type

M-x org-agenda-list-stuck-projects

but that's way too cumbersome.  I suppose I could just find another key combination, but I want it to start with C-c aand I'm not so sure how to proceed with this.
Suggestions?


texts: How can I use #+CALL with multiple arguments?

texts:
I'm trying to learn how to use the noweb syntax and advance my knowledge on the possibilities of org babel. For that, I'm trying to get the following an example to work that 1. uses noweb syntax and 2. calls the tangled function later on in the code.

Here is the code:

# This is the function that needs to be tangled
#+NAME: fast-multiplication
#+BEGIN_SRC scheme :noweb yes :var a=1 :var b=1
(define (fast-multiplication a b)
<<double>>
<<halve>>
(cond ((= b 0) 0)
      ((even? b) (fast-multiplication (double a) (halve b)))
      (else (+ a (fast-multiplication a (- b 1))))))
#+END_SRC

Now, we'll need procedures for doubling and halving. We can write them down here:

#+NAME: double
#+BEGIN_SRC scheme
(define (double a)
  (+ a a))
#+END_SRC

#+NAME: halve
#+BEGIN_SRC scheme
(define (halve a)
  (/ a 2))
#+END_SRC

# I couldn't find examples in the documentation to check my syntax.
# I think this line here is wrong..
#+call: fast-multiplication(a=5,b=7)

#+RESULTS:
: "An error occurred."

So I get an error, which I think comes from the way I'm calling the function? Everything works fine if I try it directly on the REPL.


texts: what backend package does spacemacs use for layout managment?

texts:
I saw a neat demo of the spacemacs layout feature:
demo of the spacemacs layout feature, and another one.

What package do they use to do that or another similar vanilla emacs package?


texts:
Windows 10 (64 bit), Emacs 26.1

Here my init.el

(require 'openwith)
;; Settings for package "openwith"
(when (require 'openwith nil 'noerror)
  (setq openwith-associations
        (list
     (list (openwith-make-extension-regexp '("doc" "docx" "rtf")) "word" '(file))
     (list (openwith-make-extension-regexp '("mpg" "mpeg" "mp3" "mp4" "avi" "wmv" "wav" "mov" "mkv")) "vlc" '(file))
     (list (openwith-make-extension-regexp '("pdf")) "FoxitReader" '(file))
     (list (openwith-make-extension-regexp '("png" "gif" "bmp" "tif" "jpeg" "jpg")) "xnview" '(file))
     (list (openwith-make-extension-regexp '("rdp")) "Remote Desctop Connection" '(file))
     (list (openwith-make-extension-regexp '("xls" "xlsx")) "excel" '(file))
         ))
  (openwith-mode 1))

So when I in dired mode enter over file with extension  "xls" that start default application Excel and open this file. Nice.

But what about bat and exe files? How I can run it from dired mode?


texts: web-mode javascript auto-indenting without semicolons

texts:
I'm editing JSX files with web-mode and our project doesn't use semicolons at the end of the line.

Whenever I press enter at the end of the line, web-mode is auto-indenting two spaces because the semicolon is missing. How can I prevent this?

I've seen that this question has the same problem, but it didn't help me solve this.

As far as I know, there aren't any web-mode specific indentation rules in my emacs init.el, but to be on the safe side, here are all my web-mode settings:

(add-hook 'web-mode-hook
      (lambda ()
        (if (or (equal web-mode-content-type "jsx") (equal web-mode-content-type "javascript"))
            (flymake-jslint-load))))

(add-hook 'web-mode-hook
      (lambda ()
        ;; short circuit js mode and just do everything in jsx-mode
        (if (equal web-mode-content-type "javascript")
            (web-mode-set-content-type "jsx")
          (message "now set to: %s" web-mode-content-type))

        (setq web-mode-markup-indent-offset 2)
        (setq web-mode-css-indent-offset 2)
        (setq web-mode-code-indent-offset 2)))

(require 'flycheck)
(flycheck-add-mode 'javascript-eslint 'web-mode)
(setq-default flycheck-disabled-checkers
  (append flycheck-disabled-checkers
          '(javascript-jshint)))

Update! I just realized that this happens in lines ending with functions, but not with lines that only have variable assignments. Here's a sample:

console.log()
  cursor is here when I press enter
var blub = 2
cursor is here when I press enter.

Now I'm really confused.

Thanks!
--chris


texts: Any way to select a region using `S-down-mouse-1` without saving the region as a kill?

texts:
Using emacsw32.

The usual suggested way to make a selection using S-down-mouse-1 is to bind that to mouse-save-then-kill.

Is there a similar command which selects a region, but does not save the region?

The goal is to have the following scenario:

I have some text in the kill ring. I make a selection by holding shift and clicking the left mouse button. I delete the selection using <delete>. Then I paste something (using cua-paste) and this something is not the same as the region I just deleted.


texts: How can I tell if emacs was built with X support?

texts:
Is there a variable like system-configuration-options that will provide the computed features of the running emacs?  Specifically, I'm looking for X support (--with-x=yes|no).

Ultimately I'm trying to figure out why emacs isn't starting in GUI mode, but I recently had the bone-headed realization that I'd originally built emacs before installing any X environment.  So I re-installed X and my ./configure call does mention X and GTK, so I would imagine that the support is there, but I'm not seeing emacs use a GUI.  xeyes and even gedit work.

From ./configure:

...
checking for X... libraries , headers
...
checking for GTK... yes
checking whether GTK compiles... yes
...

After I ran make clean && make && make install, running emacs still opens in terminal mode :-(

If I can determine that emacs was indeed built with X support, I'll probably ask a separate question about why it's not working :-(


texts: Projectile not showing all files under my Git project

texts:
I'm using Projectile to index a Rails 4 project.  When I use M-x projectile-find-file to locate files using their file name, some files simply don't appear.

For example, I have a file located in app/controllers/api/v1/test_controller.rb, but typing M-x projectile-find-file entertest_controllerenter returns no results.

Is there a way to re-index the project, or figure out what's filtering out certain files?


texts:
I need to combine two lists elementwise.
Given two lists that look something like,
(setq qux '("foo" "bar" "baz"))
(setq quux '("xyzzy" "thud" "blat"))

I need to use each corresponding element to form a new list,
("foo:xyzzy" "bar:thud" "baz:blat")

I could create a function that defines each element of the desired list,
(defun combiner (a b)
  (format "%s:%s" a b))

but then its not clear how I would pass the base lists in.
Another approach might be to combine the base lists into one, maybe an alist, and then pass that into a combiner function via mapcar.  The trouble is, I'm not sure how to combine the two lists elementwise.  Thoughts?


texts: How to make helm-mark-ring/helm-imenu follow current candidate

texts:
When I use helm-mark-ring or helm-imenu, I would like to jump to the current candidate automatically in the other buffer while keeping the helm session (i.e., similar to helm-swoop).
I tried the following codes mentioned on this thread, but didn't work for me.

(add-hook 'helm-before-initialize-hook #'(lambda () (helm-attrset 'follow 1 helm-source-mark-ring)))

Result: It shows [Display not ready] in echo area when I change the helm candidate (by C-n).

Any help appreciated!


texts: Copy buffer absolute file path to the system clipboard

texts:
How can i copy the absolute path of the current open buffer to the system clipboard (i.e. ctrl + shift + v) and not (ctrl + y)

There are many solutions available for such copy, 1 and 2 but all of them doesn't work outside the emacs application.


texts:
Is it possible to convert plain text dates to Org dates automatically? I have entries in the format:

16 February 2015

which I would like to convert to Org dates: <2015-02-16 Mon>


texts: How to only show the file/directory column in a Dired buffer

texts: When visiting a directory: In the view that comes up, I want the file/directory names to be in the left-most column.   How can I do that?


texts: Perform-replace only on text (no comments, no math) in latex-mode?

texts: I need to write some Emacs-Lisp code that uses the perform-replace function, limiting its range of action only on text (ignoring comments, in-line math and math ambients) on LaTeX documents (in latex-mode). I'd like to do that in native Emacs. Is there a way to do that without the need for external packages?


texts: org-agenda column view: displaying abbreviated FILE property

texts:
I would like to display file names in my global TODO list in column view without directories and extensions.

(setq org-columns-default-format "%TODO %FILE %ITEM") followed by
C-catC-cC-xC-c leads to something like

Global list of TODO items of type: ALL Available with ‘N r’: (0)[ALL]
(1)TODO (2)QUICK (3)WAITING (4)NEXT (5)STALL (6)DONE (7)CANCELLED
TODO   | c:/Users/micha/Dropbox/org/175-stuff.org                      | * Todo 1
TODO   | c:/Users/micha/Dropbox/org/175-stuff.org                      | * Todo 2
TODO   | c:/Users/micha/Dropbox/org/175-stuff.org                      | * Todo 3
TODO   | c:/Users/micha/Dropbox/org/250-petcare.org                    | * Clean dog

I tried setting up a summarizer with

(setq org-columns-default-format "%TODO %FILE{filenamebase} %ITEM")

(defun summarize-file-name-base (values printf)
  (format (or printf "%s") (file-name-base (car values))))

(add-to-list 'org-columns-summary-types '("filenamebase" . summarize-file-name-base))

If I go back to the agenda list and refresh with g then go back to column mode with C-cC-xC-c I get org-entry-put: The FILE property cannot be set with ‘org-entry-put’. If I remove the file-name-base call from the summarizer so that it just returns its input in the case of a list of a single string I don't get an error but I also get no change in formatting.

(defun summarize-file-name-base (values printf)
      (format (or printf "%s") (car values)))

Is there another way to do this?


texts: How to open a file which looks like unicode in emacs

texts:
I have a file in my C: drive on Windows named MSDELog.log and from opening the file with a hex editor I can see that there is a null character after each character.  But there is no indicator at the start of the file saying unicode or whatever the encoding is.
If I open this file with the Windows notepad it seems to recognise it and opens correctly.
If I open the file in emacs I see the text but every other character is ^@ - I realise this indicates a null character.
If I hit m-x revert-buffer-with-coding-system and try utf-8 there is no change in the view.  If I select utf-16 then I see a load of what looks like Chinese characters.
How do I view this file in emacs?


texts: Faster way than `C-u C-c C-l` to create an org link to a file opened in another buffer

texts:
Suppose I am am writing an org file /path/to/foo/bar/notes.org and I have in another window opened at the same time another file say /path2/to2/foo2/bar2/file.tex (living on a totally different path in the filesystem). Now I want to insert a link to file.tex into my org file. To do so, I would use C-u C-c C-l and then then navigate from /path/to/foo/bar/ to the file to insert the link.
Is there a faster way to insert the link which uses the fact, that the file file.tex is already opened in another window.


texts: ispell word M-$ goes into screen capture mode on MacOS

texts:
I am on Mac OS X El Capitan.

Here is my version info.

GNU Emacs 25.3.1 (x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version 10.11.6 (Build 15G31)) of 2017-12-03

Problem:
Like most Emacs users on Mac OS I have remapped Meta to  ⌘
. So now when I try to do isepll-word by doing M - $ it goes into screen capture mode of Mac OS. (The way to take a screen capture of a selected portion of your screen is to do shift - ⌘ - 4), which unfortunately is the same as M - $.

Question?
I when I am in Emacs I want to be able to M - $ and go into the choices for spellings. I know that I can enter this as an extended command as M-x: ispell-word. But I'd rather be able to do this with the keyboard shortcut.How can I fix this?.


texts: I'm trying to find out if there is way to schedule a mail for later delivery in Gnus. I am not trying to just queue a mail to be sent whenever a connection becomes available, but I am looking for a feature to define a date at which a mail is to be sent.


texts: Eshell -- how to use authinfo for login credentials

texts:
Tramp with dired-mode can use the authinfo file to automatically login.  This avoids setting up keys in the .ssh directory and also on the remote server.

Q:  How can I modify the behavior of eshell to access the authinfo file to automatically login to a remote server.

[CAVEAT:  I do not want to piggy-back by opening a Tramp dired-mode buffer and then launching eshell -- i.e., I want eshell to access the authinfo file without the help of dired-mode.]

[I am aware of the option to use a utility called sshpass, but I'd like to use the authinfo file.]


texts: Display lines aligned with right edge of buffer?

texts:
I'm running a test suite in a shell buffer that tends to produce really long lines with PASSED or FAILED at the end of them.

I'd like to be able to quickly see whether a given line passed or failed as the text scrolls past, but without throwing away the first part of the line in case. (I have a short script that reads lines and prints the last 80 characters padded on the left with spaces), but I'd prefer to change how the lines are displayed within in emacs so I'm not losing information if I need to inspect a particular test case.

just to be really concrete

1) emacs -q totally stock emacs installation

2) M-x shell start shell

3) M-x toggle-truncate-lines turn off line wrapping

4) run a command like perl -e 'for $x (40..200) { printf "begin%send\n", ("." x $x); }'

You'll see begin...... and no end after the lines become too long for the terminal to display. I'd like the ends to be visible and lined up regardless of the length of the line.


texts: `create-image` works with file-location input but fails with string-of-bytes input

texts:
Am wondering if anyone can tell me what I'm doing wrong. Basically the commented out code fails.. thanks

(let* ((img-file "/tmp/x.png")
       (img-str (with-temp-buffer (insert-file-contents img-file) (buffer-string)))
       ;; (img (create-image img-str 'png))) ; inserts a small empty box
       (img (create-image img-file 'png)))   ; correctly inserts image
  (image-flush img)
  (insert-image img))


texts: Can you render the latex math expressions in the following file successfully: http://github.com/Anton-Latukha/haskell-notes/README.org?

texts:
Can you render http://github.com/Anton-Latukha/haskell-notes/README.org using M-x org-latex-preview on the inline math expressions using Org version > 9.0 default settings?
For me, I get a weird rendering on the inline \(\) math expressions when I do M-x org-latex-preview on them wherein an image of TLT TLT and then the math expression rendered about one line below that happens in every inline math expression. Can you just tell me if the math expressions render normally for you? That way I'll know that I have something weird in my environment or config. Note: I deleted the ltximg directory that org-preview-latex feature automatically creates, so that wasn't it.
The file referenced in the subject line is the only place this happens. I can copy an inline math expression from that file and put it in a different file and it renders fine, i.e., without the TLT TLT image.
For backstory, I've ruled out or had answered my previous related questions:
org-preview-latex rendering weirdness when a space after initial inline expression delimiter
and
https://tex.stackexchange.com/questions/551266/strange-rendering-of-latex-fragments-in-org-mode-buffer
which led up to this special case. It only happens in this file.


texts: Emacs open all buffers in read only mode

texts:
This problem is driving me crazy. Emacs open all buffers including new ones in read only mode (yes, I know that I can do C-x C-q). I've tried everything including:

Delete .emacs.d/
Delete .config/emacs/init.el
Delete .emacs.el
Launch Emacs as: emacs -q -Q --debug-init (no errors, same behavior)
Reinstall Emacs.

I am using gentoo. I've create a new user (guest). Emacs works as expected. I guess the problem is somehow related to my user.
I can open a file in nano, edit it and save it. No problem. Afterwards, I open the same file in emacs it opens in read only mode. I have to hit Ctrl-Q to edit it. I can save it without problems. It's an emacs problem
All the files have write permission, that's why I can open and edit them in nano for instance.
Any help would be much appreciated.


texts: Where is Emacs installed by default on Ubuntu? I need to find its path so I can use it on another application. I am using Ubuntu 14.04 and Emacs 24.


texts: Why are leading spaces colored before comments in makefile-mode?

texts:
In Makefile mode, leading spaces are fontified in makefile-space face (bright pink without customization), when there is no other text on the line. It seems to indicate incomplete lines, and makes sense for that. The color gets back to white when you add proper rules.

Why are leading spaces before comments colored ? Their lines seem to be okay.


texts:
I wrote this code to bind both Alt+c and F5 to compile

(defun dg/cedet-hook()
  (add-to-list 'ac-sources 'ac-source-semantic)
  (local-set-key (kbd "C-c C-j") 'semantic-ia-fast-jump)
  (local-set-key (kbd "M-c") 'compile)
  (local-set-key (kbd "<f5>") 'compile)
  (yas-global-mode 1)
  )

(add-hook 'c-mode-common-hook 'dg/cedet-hook)

But, when I open a .cpp file Emacs returns the following error:

File mode specification error: (invalid-function (local-set-key (kbd <f5>) (quote compile)))

I don't undertand what's wrong in the syntax above, and why the error triggers in only the statement which uses F5.

Any clue?
Thanks in advance.


texts: How to change what modeline displays, based on major mode?

texts: i know i can change what info to display in modeline in mode-line-format variable. But how to display mode-line-position for one mode, but not display it for another?


texts:
After opening a file with emacsclient -nw foo.txt I see

When done with a buffer, type C-x #

in the minibuffer.

I however habitually do C-x C-c instead of C-x #

Is there a practical difference between the two?


texts: I recently discovered impatient mode and that's super fun to use. Are there any other libraries that use httdp server? And what might be some other uses of the server apart from serving files?


texts: It seems that org-timer (org-clock) slows down Emacs when I display it in the mode line. Is there a way for it to not affect the speed while I keep it running and visible in the mode line? e.g. by changing the update speed? Currently I can see it count every second in the mode line. Or is there an lighter alternative?


texts: Is it possible to wait for user in a loop?

texts:
I'm trying to write a function for complete in minibuffer with history.

(Terminal equivalent of "\e[5~": history-search-backward in ~/.inputrc)

With the below function I can get the last command that start with the prefix in the minibuffer. I want to validate this candidate or search the next candidate.

(defun history-search-forward ()
  (interactive)
  (setq prefix (minibuffer-contents))
  (loop for elt in extended-command-history
        do
        ;; history starts with word-at-point
        (and (string-match (rx-to-string `(: bos ,prefix) t)
                           elt)
             (progn
               (delete-region (point) (line-beginning-position))
               (insert elt)
               ;; here a want to launch the command if <Enter>
               ;; or continue looping if <prior>
               (return)))))
(define-key minibuffer-local-completion-map (kbd "<prior>") 'history-search-forward)

How can I wait for user input at that point in the loop?


texts:
I use Org mode for keeping track of everything; ideas, notes, to-do lists, code snippets, etc. You name it. One problem I have though, is that I can't easily pull up my Org-mode data on my phone, even if it is only for quickly checking my notes or searching within them.

To be clear, I store my org files within a Github repository, which is great, but this is still not amenable for smartphone browsing and searching.

Ideally what I am looking for is a way to synchronize org-mode notes with Evernote. Is this doable? If not, what are my alternatives for browsing org-mode files on my phone?

How can I easily sync, and later browse and search my org-mode files from my phone?


texts: Collapse xml-node-children from `xml.el` into a string

texts:
An API I have used for years (via an elisp package)
recently started inserting formatting tags
(particularly for <i></i> italics)
into the 'ArticleTitle' field of entries.
The assumption that the node-child of 'ArticleTitle' field is a single string
is thus no longer valid,
causing trouble shortly downstream.

I think I need help in either A) stripping out the formatting tags
or B) joining the child-nodes into a single string
to restore function.

I attempted to document the context
in which this question arose
at https://github.com/jshoyer/pubmode/issues/3
(a fork of the original package)

Googling this subject
and reading the xml.el source code
have both proved difficult.
Advice on search query terms
or how to construct a minimal reproducible example would be welcome.
Perhaps basic elisp list manipulation (without requiring any further use of xml.el) would suffice.
I would prefer not to use other emacs tools beyond xml.el.


texts: How do you type a space character in Spacemacs?

texts:
I was researching editors and I ended up stumbling upon Spacemacs and the fact that it uses the spacebar instead of traditional modifier keys. The documentation claims that this lowers the user's risk of RSI. Okay that seems reasonably plausible I guess, but it raises the question of how do you type the space character, " " if the key has a different meaning? I don't see how you could avoid needing to do that.

Surprisingly, I am unable to find the answer in the documentation. This FAQ doesn't have the answer either. I'm guessing that it's somehow obvious if you use the program, since it's apparently not a commonly asked question, but I don't want to install the program just to find out. Hence I'm asking the question here.


texts: How to overwrite a defcustom of a package within the initfile?

texts:
I have an installed packages (say mypackage.el) in \.emacs.d\lisp\ directory. In that package there is

(defcustom xyz "path1" "Path to the program"
  :group 'blablabla
  :type 'string)

I would like to change the above as

(defcustom xyz "path2" "Path to the program"
  :group 'blablabla
  :type 'string)

I prefer to do this modification not in the package el file but in my init file. However adding the above in the init file has no effect and for the package the variable xyz is always path1.


texts:
Using web-mode and evil I get a really strange behaviour when pressing return after curly braces:

let StubMapsService = Ember.Service.extend({
    getMapElement(location) { (RET)
        }
});

let f = function(assert) { (RET)
    }

RET is set to "evil-ret".

When writing java-files the Indentation is correct after inserting }.

Also when I press C-c TAB in web-mode, so web-mode auto-indents the buffer, then everything looks correct:

let StubMapsService = Ember.Service.extend({
    getMapElement(location) {
    }
});

let f = function(assert) {
}

I searched for an hour for a solution. I tried changing c-indent-offset, setting web-mode-code-indent-offset, but nothing helped. Turning off electric-indent-mode I get no indentation after pressing RET. Any Idea what is going wrong?


texts: calling xref-find-definitions within lisp code

texts:
I want to call xref-find-definitions from within my own lisp code and I'm struggling.

  (xref-find-definitions IDENTIFIER)

  Find the definition of the identifier at point.

It wants a parameter but I don't understand what parameter to supply because if I call it directly it just reads the name of a function from (point) and finds the source code for me.

As background, I maintain a private mark-ring with functions to (un)rotate-and-go and I want to combine go-to-source-of-function-named-at-point and push-point-onto-private-mark-ring as one key-combination.

I'm aware of bury-buffer and wrote my own unbury-buffer.


texts: What is the proper way to setup a package with Spacemacs?

texts:
I have been reading very good thing about Spacemacs, and decided to give it a try. Right now I am trying to port my (messy handwritten) configuration to it, and the Spacemacs way to do it is by creating a layer (or so I think).

And I have a few doubts:

I use org-journal, and it can only be loaded after org. What should I put in my <layer>-packages list? Just org-journal or both org-journal and org?
Where is the appropriate place to setup things like org-agenda-files and org-todo-keywords?


texts: hs-minor-mode and sage-shell-mode (derived from python-mode)

texts:
I would like to use emacs' hide-show mode (to collapse class and function definitions) with Sho Takemori's sage-shell-mode (for the SageMath computer algebra system) which derives from python-mode.

Although emacs does not complain when I do M-x hs-minor-mode, it does not work, in particular, M-x hs-hide-all does not appear to be doing anything.

sage-shell-mode is available at https://github.com/sagemath/sage-shell-mode


texts:
I am correctly connected to my channels, I can read updates, but besides that, I cannot post messages to any channel, IM or group...
slack mode always responds:
[timestamp] [error] [channel_name] Failed to post message. Error: invalid_post_type, meta: nil

I have really no idea what's going on, I once could post messages with no problems, but suddenly this began to happen


texts: How to count regexp in a string and use that number in replacement?

texts:
In my LaTeX code I want to replace these strings:

\left.\left.\left.
\left.\left.
\left.

with:

\left.\left.\left. \mycommand{3}
\left.\left. \mycommand{2}
\left. \mycommand{1}

where the argument of the command \mycommand is the number of the occurrences of the regexp `"\\left\." in each string.

My question is: can I obtain it by a query-replace? I figured out something like:

(query-replace-regexp "\\(\\(:?\\\\left\\.\\)+\\)"
                      `(,(lambda (x y)
                           (let* ((MATCH (match-string 0))
                                  (OCCURRENCES
                                   (my-count-regexp "\\\\left\\."
                                                    MATCH))
                                  (OCCURRENCES (number-to-string OCCURRENCES)))
                             (concat MATCH "\\myfunction{" OCCURRENCES "}")))))

But I didn't find a function (my-count-regexp in my code) that returns the occurrences of a regexp in a string.

Also I'm not shure of the lambda function syntax.

Edit. I found that the following code works, but I'm still searching for something simplier:

(query-replace-regexp "\\(\\(:?\\\\left\\.\\)+\\)"
                      `(,(lambda (x y)
                           (let* ((MATCH (match-string 0))
                                  (OCCURRENCES
                                   (with-temp-buffer
                                     (insert MATCH)
                                     (goto-char (point-min))
                                     (count-matches "\\\\left\\.")))
                                  (MATCH (replace-regexp-in-string "\\\\"
                                                                   "\\\\\\\\" MATCH))

                                  (OCCURRENCES (number-to-string OCCURRENCES)))
                             (concat MATCH "\\\\myfunction{" OCCURRENCES "}")))))


texts: Org's Capture: annoying duplicated date tree outlines

texts:
(Environment: Emacs 24.4 stable with built-in org-mode.)

I want to have a file+datetree for Org-mode's Capture, so I set like this:

(setq org-capture-templates
      '(("D" "Diary + Timer" entry
         (file+datetree (concat org-directory "/diary/diary.org"))
         "* %^{Description: } %^g  \n  %i %?\n" :clock-in t :clock-keep t)
        ("d" "Diary" entry
         (file+datetree (concat org-directory "/diary/diary.org"))
         "* %? %U")
        ))

And use these captures to add items for diary.org several times. I expect the file has:

* 2014
** 2014-11 11 月
*** 2014-11-21 金曜日
**** test1 [2014-11-21 金 03:08]
**** test2 [2014-11-21 金 03:08]
**** test3 [2014-11-21 金 03:08]

But what I get is like this:

* 2014
** 2014-11 11 月
*** 2014-11-21 金曜日
**** test1 [2014-11-21 金 03:08]
** 2014-11 11 月
*** 2014-11-21 金曜日
**** test2 [2014-11-21 金 03:09]
** 2014-11 11 月
*** 2014-11-21 金曜日
**** test3 [2014-11-21 金 03:09]

How to solve this problem...? (I've ever used Org's Capture one year ago, and it worked just liked I wish; I have no idea why it becomes this.)

[Edited] Finally, totally out of expect, the problem is resulted from Pangu-Spacing....
https://github.com/coldnew/pangu-spacing/issues/5


texts: Export settings question from Beamer example written by org-mode

texts:
A minimal example can be found in Here

Can anyone explain the following line funtion?

#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)

The worg says

  for a column view of options and configurations for the individual frames

But a sentence can't make me understand.
To do a test, I change the number in it but finding the output frame doesn't change.


texts: I can resize the emacs frame to whatever size by mouse, is there a way that the frame size be set in init.el by pixels? Or anything similar in the window manager?


texts: Run command on remote host after org-publish

texts:
I try to setup a basic, easy website workflow. Right now I can simply press C-e P x project-name, export and upload my Org, image, and whatnot files as HTML.
As I don't want to upload that directly into /var/www, because you'd need special permissions, I want to run a command right after publishing on my webserver.

Is there a more elegant (better: more robust) way of solving the issue, besides running some kind of command/script after org-publish?

I tried to do that via inotify/a random inotify script I found on SO, but it won't recognize the changes I made, poor inotify script. :(


texts:
Is there a way to edit a file only once?
So that for example: I open it and its closed (the buffer is killed) after the window closes.
A clarification: I usually have an Emacs deamon running and open windows with emacsclient -nc [file], but I don't want to have every file in my buffer list and I dont want to open a single instance for every file I only edit once.

Any ideas?


texts: How to put buffers named with an asterisk at the end of ido's selection list?

texts:
with (ido-switch-buffer), when I type stuff, "*magit: stuff*" comes before Stuff.txt.

the sorting seems to be done by recency, rather than the buffer name. more generally, a custom sort function would be nice.


texts: How to modify interactive function `occur` to a non-interactive function

texts:
occur is an interactive compiled Lisp function in ‘replace.el’.
The definition is as follows:
(defun occur (regexp &optional nlines region)
  (interactive
   (nconc (occur-read-primary-args)
          (and (use-region-p) (list (region-bounds)))))
  (let* ((start (and (caar region) (max (caar region) (point-min))))
         (end (and (cdar region) (min (cdar region) (point-max))))
         (in-region-p (or start end)))
    (when in-region-p
      (or start (setq start (point-min)))
      (or end (setq end (point-max))))
    (let ((occur--region-start start)
          (occur--region-end end)
          (occur--matches-threshold
           (and in-region-p
                (line-number-at-pos (min start end))))
          (occur--orig-line
           (line-number-at-pos (point)))
          (occur--orig-line-str
           (buffer-substring-no-properties
            (line-beginning-position)
            (line-end-position))))
      (save-excursion ; If no matches `occur-1' doesn't restore the point.
        (and in-region-p (narrow-to-region start end))
        (occur-1 regexp nlines (list (current-buffer)))
        (and in-region-p (widen))))))

When the above function is invoked, the user is prompted to input a regexp for searching.
What I want is to make a new function myoccur by hard-coding a regexp in the above function and make it non-interactive, so that I can conveniently invoke it. If a wrapper over the original occur can make it non-interactive, that would also be great.
How should I do?


texts: How to replace an object with selection?

texts:
In Evil mode, is it possible to prevent change and deletion commands from putting the replaced object into the selection (system clipboard)? I would like yanking to still do so.

I'd like to be able to yank an object (or copy it in another application), then move to the destination, press cw to replace it, and press Cmd-V to paste the source text. The standard behaviour is for all yank, change, and deletion to go to the unnamed register, which is also used for pasting, which means that I have to resort to "viwp" or "cwC-r 0".


texts: How can I use ERC with an IRC offered over SSL?

texts:
I'm trying to connect to Gitter's IRC servers to join the chat room vermiculus/stack-mode, but according to Gitter, they offer this service over SSL:

      _                 _ _   _            _
     (_)_ __ ___   __ _(_) |_| |_ ___ _ __(_)_ __ ___
     | | '__/ __| / _` | | __| __/ _ \ '__| | '_ ` _ \
     | | | | (__ | (_| | | |_| ||  __/ |_ | | | | | | |
     |_|_|  \___(_)__, |_|\__|\__\___|_(_)|_|_| |_| |_|
                  |___/

"Life is really simple, and so is to use Gitter IRC" - Confucius
what is Gitter?

man irc.gitter.im (this service is still very much beta)
1. Connect to irc.gitter.im with your IRC client using SSL
2. /PASS <my token has been redacted for obvious reasons>
3. /NICK vermiculus
4. Profit

100% compatible with Lynx. Seriously.

However, I cannot find any mention of SSL in ERC's Info manual.  How can I specify that the connection should be secure?  I believe this is the reason I receive the error:

[Sun Nov 23 2014]

Connection failed!  Re-establishing connection...               [23:21]

[Sun Nov 23 2014]
ERC> /join vermiculus/stack-mode                                [23:22]
ERC> /join vermiculus/stack-mode

Connection failed!  Re-establishing connection...

[Sun Nov 23 2014]

Connection failed!  Re-establishing connection...               [23:23]

[Sun Nov 23 2014]
ERC> /PASS <again, redacted>                                    [23:23]
ERC> /NICK vermiculus

Connection failed!  Re-establishing connection...               [23:24]

[Sun Nov 23 2014]

Connection failed!  Re-establishing connection...               [23:24]

ERC>


texts: run a binary that uses ncurses in eshell under xterm-256color emulation

texts: I have a binary (a rust program that uses bindings to ncurses) and I need to run it in eshell as xterm-256color (well, make it work correctly at least). I haven't figured out how to do this yet. Tried setting TERM to xterm-256color, but that didn't seem to help. Is there even a way to do this?


texts:
First of all, I am not familiar with how emacs-nox is implemented internally.
Suppose we can access framebuffer directly (/dev/fb...)
Is it possible to access the framebuffer directly using emacs?
For example, I want to view pictures or pdfs using emacs-nox.
I believe this is totally feasible since I can see pictures and videos on tty using fbi or mplayer.


texts: Language specific comments in org-mode source code blocks

texts:
I have language specific syntax highlighting and (kind of) indentation working in Org-mode source code blocks.

However, because of the syntax highlighting if I am editing the code block in the Org-mode buffer, I often find myself thinking that I am in an e.g., emacs lisp buffer. When I try to comment out code in one of these blocks though, I get # at the begining of the comment, instead of the delimiter for the language of the source code block. This mean that commenting is often a 4 step process of:

Comment the code with M-; leading to code that has the wrong style comment.
Uncomment that code.
Call org-edit-special with C-c ' to get to a buffer specific to the language.
Comment out the code again (and usually go back to the org-mode buffer).

I would like to do this with only the first step if possible. Is there a way to use language specifc comments in org-src block?


texts: changing the role of the underline and the minus-sign just in LateX-mode

texts:
During the work with tex files with auctex+emacs (LateX-mode), I use more frequently _ (underline) instead of - (minus sign).
The same as ^ instead of 6.
The inconvenience is that I should press more frequently the shift-key.

It would be desirable to customize emacs in such a way that when emacs is in LateX-mode (and just in this mode), when I type - the the emacs types _ and when I type _ the emacs types -.
i.e., the following key-bindings:

- gives _

_ gives -

6 gives ^

^ gives 6

Is it possible?


texts: Why can't I list the contents of Desktop on macos using dired?

texts:
When I do C-x C-f on ~/Desktop/ in macos Catalina, I get the following error.

Listing directory failed but 'access-file' worked

I can list the directory for just ~.

I'm new to Emacs and know little else. I've tried installing Emacs through Homebrew and using a binary from https://emacsformacosx.com

I've also searched for that error where some people said there's an issue with ls on mac, but I don't have any problem listing the contents of ~. Also, I didn't find any clear solution to that problem (I tried copy pasting answers to my init file but that didn't solve anything).


texts: I want to use mac-ports python instead of default Apple. When I exec run-python I get the default python. I could not find any reference under customize-groupand customize-variable.


texts: Execute external script upon save when in a certain mode?

texts:
When I'm in org-mode, I want Emacs to execute a bash script I wrote whenever I hit C-x s to save.  The script automatically syncs the file I am saving to my Raspberry Pi. It expects the file name as argument.

How do I tell Emacs to run the external script on org files when I save?


texts: Org mode: how to display tree content only via Elisp

texts:
I'm new to Elisp and I'd like to start using Emacs org Mode as my main writing tool. For that to happen I'm trying to set up a good configuration with custom functions. What I'm trying to achieve is "display the org document as content only". When I press SHIFT+TAB in Org mode, the buffer cycles between "Overview", "Content" and "Show All". I found that I could switch to "Overview" using command org-overview, but I can't find how to activate "Content" or "Show All" using Elisp.

EDIT:
Here is the different style of one simple org document. What I want to find is what commands could swap my document state to "Content" or "Show All":

Overview:

Content:

Show All:


texts: How to narrow to subtree in org agenda follow mode?

texts: When org-agenda-follow-mode is on, how do I make the buffer showing the items in the agenda narrow to the subtree of the relevant item?


texts: How to cofigure smart double brackets for links?

texts: I use double brackets heavily for links. Is there anyway to config smart autocompletion such that pressing brackets twice I get [[] instead of [[]], and once the prompt is at left of ] in [[], pressing ] again close the link, that is, produces the final [[]]?


texts: How to use org-refile with helm to create a new node?

texts:
I'm trying to use Helm with org-refile. It looks like everyting is working properly except one thing.

For example, I have the following tree in my org file:

* Top level 1
** Example heading
* Top level 2

I want to refile "Example heading" to a new node under "Top level 2". Result should look like this:

* Top level 1
* Top level 2
** New node
*** Example heading

I already setup org-mode so it creates new node without any issues. The problem is that Helm doesn't provide any completion, so every time I should type the whole string, then I need to add "/New node" and press Enter.

I tried to use Control-Z which works fine when finding files, but not in org-refile. Is there a way to solve such issue?


texts:
I want to make specific faces read-only.
For example, I want to make all org-mode headlines and drawers to be read only (among other things)
Pieces of the puzzle I've looked into:

Preventing deletion of hidden text
the text property read-only
there are overlays that can be used to apply properties to regions
I don't think there's a face attribute for read-only from what I saw in customize


texts: Dired: move cursor to last position when entering a subdirectory again?

texts:
When dired moves up a directory, in the new buffer, the cursor will be positioned on the directory from where it originated.

However, the other way around is not supported by default: upon returning to a subdirectory, the cursor will be placed on the first line of the dired list regardless of the file or directory that had been most recently visited in this subdirectory. This behaviour can be confusing when quickly switching between dired buffers.

Is it possible to make dired act in the intended way when entering a subdirectory?


texts:
In the documentation for shell-mode:

  Emacs sends the new shell the contents of the file
  ~/.emacs_shellname as input, if it exists, where shellname is the
  name of the file that the shell was loaded from. For example, if you
  use bash, the file sent to it is ~/.emacs_bash. If this file is not
  found, Emacs tries with ~/.emacs.d/init_shellname.sh.

Everything works as expected when I enter shell-mode with M-x shell. However, this doesn't work when I call term or ansi-term in Emacs. I have both ~/.emacs_bash and ~/.emacs.d/init_shellname.sh containing export PS1='\h:\W$ ', but the prompt is still bash-3.2$.

How to set a startup shell script for term-mode?